胃胀不舒服吃什么药| 月经期间不能吃什么水果| 词讼是什么意思| 养心吃什么| 崩漏下血是什么意思| 体毛旺盛是什么原因| 七点到九点是什么时辰| 什么叫天干| 跟腱炎贴什么膏药最好| 小郡肝是什么部位| 笨拙是什么意思| 肌肉拉伤看什么科室| 赛马不相马什么意思| 小叶增生吃什么药| 早上喝豆浆有什么好处| 人的牙齿为什么不能再生| 什么人容易得白肺病| 岁寒三友指什么| 织锦缎是什么面料| 黑乌龙茶属于什么茶| 鲤鱼最爱吃什么食物| 劼字取名的寓意是什么| 东北有什么好玩的景点| 浮躁什么意思| 月经期适合吃什么水果| 血小板减少吃什么| 柴鸡是什么鸡| 1997年属什么生肖年| 病毒感染会有什么症状| 用盐洗脸有什么好处| 运是什么结构| 吃了布洛芬不能吃什么| 叛逆期是什么意思| 什么风呼啸| 肠穿孔有什么症状| cc是什么牌子| 枸橼酸西地那非片有什么副作用| mz是什么意思| 慢性胰腺炎吃什么药效果最好| www是什么网| 体检前一天晚上吃什么| 血管病变是什么意思| 男人阴虱用什么药| 秋天穿什么| 什么的看| 小儿急性喉炎吃什么药| 盆腔炎是什么症状| 霸道是什么车| 贝贝什么意思| 男生下面叫什么| op什么意思| jackjones是什么品牌| 磨人的小妖精是什么意思| 什么是排卵期怎么计算| 什么时候冬天| 青出于蓝是什么意思| 什么蓝| 心是什么意思| 一个木一个寿念什么| 1月29日什么星座| 1月30号是什么星座| 十二指肠胃溃疡吃什么药| c反应蛋白高吃什么药| 心肌缺血吃什么药效果最好| 翡翠五行属什么| 下眼睑浮肿是什么原因| 一个木一个舌读什么| 逸五行属性是什么| 糖类抗原199偏高是什么原因| 肥猪拱门是什么生肖| 每个月月经都推迟是什么原因| 市政协副主席是什么级别| 痔疮吃什么好| 脸上长痘痘去医院挂什么科| 月经稀发是什么意思| 白带黄吃什么药| 现在什么手机好用| hello什么意思| 妊娠线什么时候长| 贫血吃什么补的快| 乳腺钙化是什么意思啊| od是什么意思| 蓝莓什么时候成熟| 宋美龄为什么没有孩子| eva鞋底是什么材质| 女性缓解疲劳吃什么好| 口坐读什么| 梦见把狗打死了是什么意思| pangchi是什么牌子的手表| 心脏大是什么病严重吗| 谨记的意思是什么| 毫不犹豫的意思是什么| 溢于言表什么意思| 磋商是什么意思| 结甲是什么意思| 肌酐偏高是什么意思| 降血糖的草都有什么草| 211大学什么意思| 五官端正是什么意思| 临床药学在医院干什么| 佛珠断了有什么预兆| 为什么嘴巴老是干| 扶乩是什么意思| 梦见别人给钱是什么意思| 什么叫主动脉硬化| 近水楼台先得月是什么生肖| 燕然未勒归无计的上一句是什么| 和是什么意思| 鬼谷子姓什么| 旧历是什么意思| 没什么好怕| 房性期前收缩是什么意思| 双手合十什么意思| 苏州机场叫什么| 小孩吃什么通便降火| 微量元素6项是查什么| 右胳膊麻木是什么征兆| 兰花象征着什么| ng什么意思| 四季常青财运旺是什么生肖| 盖是什么意思| 会考没过有什么影响| gdp指的是什么| 狂犬疫苗打在什么部位| 梦见自己有孩子了是什么预兆| 吃完避孕药有什么反应| 农业户口和居民户口有什么区别| 非特异性t波异常是什么意思| 有色眼镜是什么意思| 梦见煤是什么意思| 什么是认知障碍| 淋巴结是什么| 碧根果和核桃有什么区别| 汗水里面有什么成分| 阿迪达斯是什么牌子| 帕金森吃什么药好得快| 梦见摘桃子是什么意思| 水煮鱼用什么鱼做好吃| 为什么白带是绿色| 下限是什么意思| 圣女果是什么| 小便尿血是什么原因| 月经9天了还没干净是什么原因| n标志的鞋子是什么牌子| 什么是阴蒂| 口爆什么意思| 左侧卵巢多囊样改变什么意思| 店里来猫是什么兆头| 11月17是什么星座| 黄皮是什么水果| 腰椎间盘突出吃什么好| 智齿是什么样的| 肾结石可以喝什么饮料| 胃一阵一阵的疼吃什么药| 2月3日什么星座| 肚子里有积水是什么病| 二十四节气分别是什么| 什么是薪级工资| 导购员是做什么的| 梦见杀牛是什么预兆| cream什么意思| 茶色尿是什么原因引起的| 羊绒和羊毛有什么区别| izzue是什么牌子| 体检前需要注意什么| cd138阳性是什么意思| 梦见做春梦是什么意思| 甲功五项挂什么科| 点天灯是什么意思| 尿ph值高是什么意思| 桃李满天下的桃李是什么意思| 煎饼果子的果子是什么| 过渡句的作用是什么| 氢氧化钠是什么| 仁慈是什么意思| 肝功能七项是检查什么| 10月1日是什么日子| 继发性肺结核是什么意思| 多晒太阳有什么好处| 天丝是什么材料| 苹果的英文是什么| 鬼畜什么意思| 谷草转氨酶偏低是什么意思| 灵芝什么人不能吃| 孕妇吃坚果对胎儿有什么好处| 什么狗最贵| 脑梗做什么检查最准确| 胃反流吃什么药效果好| 内膜薄是什么原因| 固体玉米糖浆是什么| 皮肤偏黄适合穿什么颜色的衣服| 刮痧红色说明什么原因| 锡兵是什么意思| 唐僧是什么生肖| 嘴唇发紫是什么病| 验孕棒阳性代表什么| 谢谢谬赞是什么意思| 胆结石有什么症状有哪些| 什么地流| 肺部结节有什么症状| 口腔异味吃什么药| 状元及第是什么意思| 属猪的和什么属相最配| 八方来财是什么意思| 胃不好吃什么药| 荷叶泡水喝有什么作用| 见血是什么兆头| 户籍所在地是指什么| 翡翠戴久了会有什么变化| 龋病是什么意思| 吉代表什么生肖| 淋巴吃什么药好| 金克木是什么意思| 口红什么牌子最好| 骆驼奶有什么功效| 触霉头是什么意思| 7月30日是什么日子| 睡觉老是做梦是什么原因| 内参是什么意思| 一级甲等医院是什么意思| 人为什么| 6月11日什么星座| 今天什么节日| 心电图电轴右偏是什么意思| 四维空间是什么样子| 做梦梦见掉头发是什么意思| 排骨粥要搭配什么好吃| 芹菜吃多了会有什么影响| 11月1号是什么星座| 智齿是什么意思| 热络是什么意思| 草金鱼吃什么| ceq是什么意思| 中国的国花是什么花| 套路是什么意思| 股票融是什么意思| 徐长卿是什么药| 胃寒喝什么茶暖胃养胃| 睡眠好的人说明什么| 已故是什么意思| 三伏天喝什么汤最好| 胃反流是什么原因引起的| leep术是什么手术| 女生爱出汗是什么原因| 毛泽东什么时候逝世| pop什么意思| 打乙肝疫苗挂什么科| 薏米不能和什么一起吃| 一什么而入| b什么意思| 什么是阴沉木| 晚字五行属什么| 二月八号是什么星座| 什么是优质蛋白| 他喵的什么意思| ppsu是什么材质| 三岁看小七岁看老是什么意思| 胎盘2级是什么意思| 脾胃虚弱能吃什么水果| 指甲中间凹陷是什么原因| 湿疹有什么症状和图| 胆结石有什么治疗方法| 无缘无故流鼻血是什么原因| 肌酐是什么病| 百度

他克莫司是什么药


Directory: ../../../ffmpeg/
File: src/libavcodec/xpmdec.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 0 151 0.0%
Functions: 0 7 0.0%
Branches: 0 108 0.0%

Line Branch Exec Source
1 /*
2 * XPM image format
3 *
4 * Copyright (c) 2012 Paul B Mahol
5 * Copyright (c) 2017 Paras Chadha
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "libavutil/avstring.h"
25 #include "libavutil/mem.h"
26 #include "avcodec.h"
27 #include "codec_internal.h"
28 #include "decode.h"
29
30 #define MIN_ELEMENT ' '
31 #define MAX_ELEMENT 0xfe
32 #define NB_ELEMENTS (MAX_ELEMENT - MIN_ELEMENT + 1)
33
34 typedef struct XPMContext {
35 uint32_t *pixels;
36 int pixels_size;
37 uint8_t *buf;
38 int buf_size;
39 } XPMDecContext;
40
41 typedef struct ColorEntry {
42 const char *name; ///< a string representing the name of the color
43 uint32_t rgb_color; ///< RGB values for the color
44 } ColorEntry;
45
46 static int color_table_compare(const void *lhs, const void *rhs)
47 {
48 return av_strcasecmp(lhs, ((const ColorEntry *)rhs)->name);
49 }
50
51 static const ColorEntry color_table[] = {
52 { "AliceBlue", 0xFFF0F8FF },
53 { "AntiqueWhite", 0xFFFAEBD7 },
54 { "Aqua", 0xFF00FFFF },
55 { "Aquamarine", 0xFF7FFFD4 },
56 { "Azure", 0xFFF0FFFF },
57 { "Beige", 0xFFF5F5DC },
58 { "Bisque", 0xFFFFE4C4 },
59 { "Black", 0xFF000000 },
60 { "BlanchedAlmond", 0xFFFFEBCD },
61 { "Blue", 0xFF0000FF },
62 { "BlueViolet", 0xFF8A2BE2 },
63 { "Brown", 0xFFA52A2A },
64 { "BurlyWood", 0xFFDEB887 },
65 { "CadetBlue", 0xFF5F9EA0 },
66 { "Chartreuse", 0xFF7FFF00 },
67 { "Chocolate", 0xFFD2691E },
68 { "Coral", 0xFFFF7F50 },
69 { "CornflowerBlue", 0xFF6495ED },
70 { "Cornsilk", 0xFFFFF8DC },
71 { "Crimson", 0xFFDC143C },
72 { "Cyan", 0xFF00FFFF },
73 { "DarkBlue", 0xFF00008B },
74 { "DarkCyan", 0xFF008B8B },
75 { "DarkGoldenRod", 0xFFB8860B },
76 { "DarkGray", 0xFFA9A9A9 },
77 { "DarkGreen", 0xFF006400 },
78 { "DarkKhaki", 0xFFBDB76B },
79 { "DarkMagenta", 0xFF8B008B },
80 { "DarkOliveGreen", 0xFF556B2F },
81 { "Darkorange", 0xFFFF8C00 },
82 { "DarkOrchid", 0xFF9932CC },
83 { "DarkRed", 0xFF8B0000 },
84 { "DarkSalmon", 0xFFE9967A },
85 { "DarkSeaGreen", 0xFF8FBC8F },
86 { "DarkSlateBlue", 0xFF483D8B },
87 { "DarkSlateGray", 0xFF2F4F4F },
88 { "DarkTurquoise", 0xFF00CED1 },
89 { "DarkViolet", 0xFF9400D3 },
90 { "DeepPink", 0xFFFF1493 },
91 { "DeepSkyBlue", 0xFF00BFFF },
92 { "DimGray", 0xFF696969 },
93 { "DodgerBlue", 0xFF1E90FF },
94 { "FireBrick", 0xFFB22222 },
95 { "FloralWhite", 0xFFFFFAF0 },
96 { "ForestGreen", 0xFF228B22 },
97 { "Fuchsia", 0xFFFF00FF },
98 { "Gainsboro", 0xFFDCDCDC },
99 { "GhostWhite", 0xFFF8F8FF },
100 { "Gold", 0xFFFFD700 },
101 { "GoldenRod", 0xFFDAA520 },
102 { "Gray", 0xFFBEBEBE },
103 { "Green", 0xFF00FF00 },
104 { "GreenYellow", 0xFFADFF2F },
105 { "HoneyDew", 0xFFF0FFF0 },
106 { "HotPink", 0xFFFF69B4 },
107 { "IndianRed", 0xFFCD5C5C },
108 { "Indigo", 0xFF4B0082 },
109 { "Ivory", 0xFFFFFFF0 },
110 { "Khaki", 0xFFF0E68C },
111 { "Lavender", 0xFFE6E6FA },
112 { "LavenderBlush", 0xFFFFF0F5 },
113 { "LawnGreen", 0xFF7CFC00 },
114 { "LemonChiffon", 0xFFFFFACD },
115 { "LightBlue", 0xFFADD8E6 },
116 { "LightCoral", 0xFFF08080 },
117 { "LightCyan", 0xFFE0FFFF },
118 { "LightGoldenRodYellow", 0xFFFAFAD2 },
119 { "LightGreen", 0xFF90EE90 },
120 { "LightGrey", 0xFFD3D3D3 },
121 { "LightPink", 0xFFFFB6C1 },
122 { "LightSalmon", 0xFFFFA07A },
123 { "LightSeaGreen", 0xFF20B2AA },
124 { "LightSkyBlue", 0xFF87CEFA },
125 { "LightSlateGray", 0xFF778899 },
126 { "LightSteelBlue", 0xFFB0C4DE },
127 { "LightYellow", 0xFFFFFFE0 },
128 { "Lime", 0xFF00FF00 },
129 { "LimeGreen", 0xFF32CD32 },
130 { "Linen", 0xFFFAF0E6 },
131 { "Magenta", 0xFFFF00FF },
132 { "Maroon", 0xFFB03060 },
133 { "MediumAquaMarine", 0xFF66CDAA },
134 { "MediumBlue", 0xFF0000CD },
135 { "MediumOrchid", 0xFFBA55D3 },
136 { "MediumPurple", 0xFF9370D8 },
137 { "MediumSeaGreen", 0xFF3CB371 },
138 { "MediumSlateBlue", 0xFF7B68EE },
139 { "MediumSpringGreen", 0xFF00FA9A },
140 { "MediumTurquoise", 0xFF48D1CC },
141 { "MediumVioletRed", 0xFFC71585 },
142 { "MidnightBlue", 0xFF191970 },
143 { "MintCream", 0xFFF5FFFA },
144 { "MistyRose", 0xFFFFE4E1 },
145 { "Moccasin", 0xFFFFE4B5 },
146 { "NavajoWhite", 0xFFFFDEAD },
147 { "Navy", 0xFF000080 },
148 { "None", 0x00000000 },
149 { "OldLace", 0xFFFDF5E6 },
150 { "Olive", 0xFF808000 },
151 { "OliveDrab", 0xFF6B8E23 },
152 { "Orange", 0xFFFFA500 },
153 { "OrangeRed", 0xFFFF4500 },
154 { "Orchid", 0xFFDA70D6 },
155 { "PaleGoldenRod", 0xFFEEE8AA },
156 { "PaleGreen", 0xFF98FB98 },
157 { "PaleTurquoise", 0xFFAFEEEE },
158 { "PaleVioletRed", 0xFFD87093 },
159 { "PapayaWhip", 0xFFFFEFD5 },
160 { "PeachPuff", 0xFFFFDAB9 },
161 { "Peru", 0xFFCD853F },
162 { "Pink", 0xFFFFC0CB },
163 { "Plum", 0xFFDDA0DD },
164 { "PowderBlue", 0xFFB0E0E6 },
165 { "Purple", 0xFFA020F0 },
166 { "Red", 0xFFFF0000 },
167 { "RosyBrown", 0xFFBC8F8F },
168 { "RoyalBlue", 0xFF4169E1 },
169 { "SaddleBrown", 0xFF8B4513 },
170 { "Salmon", 0xFFFA8072 },
171 { "SandyBrown", 0xFFF4A460 },
172 { "SeaGreen", 0xFF2E8B57 },
173 { "SeaShell", 0xFFFFF5EE },
174 { "Sienna", 0xFFA0522D },
175 { "Silver", 0xFFC0C0C0 },
176 { "SkyBlue", 0xFF87CEEB },
177 { "SlateBlue", 0xFF6A5ACD },
178 { "SlateGray", 0xFF708090 },
179 { "Snow", 0xFFFFFAFA },
180 { "SpringGreen", 0xFF00FF7F },
181 { "SteelBlue", 0xFF4682B4 },
182 { "Tan", 0xFFD2B48C },
183 { "Teal", 0xFF008080 },
184 { "Thistle", 0xFFD8BFD8 },
185 { "Tomato", 0xFFFF6347 },
186 { "Turquoise", 0xFF40E0D0 },
187 { "Violet", 0xFFEE82EE },
188 { "Wheat", 0xFFF5DEB3 },
189 { "White", 0xFFFFFFFF },
190 { "WhiteSmoke", 0xFFF5F5F5 },
191 { "Yellow", 0xFFFFFF00 },
192 { "YellowGreen", 0xFF9ACD32 }
193 };
194
195 static unsigned hex_char_to_number(uint8_t x)
196 {
197 #define TIMES256(idx) \
198 TIMES64(4 * (idx)) TIMES64(4 * (idx) + 1) TIMES64(4 * (idx) + 2) TIMES64(4 * (idx) + 3)
199 #define TIMES64(idx) \
200 TIMES16(4 * (idx)) TIMES16(4 * (idx) + 1) TIMES16(4 * (idx) + 2) TIMES16(4 * (idx) + 3)
201 #define TIMES16(idx) \
202 TIMES4(4 * (idx)) TIMES4(4 * (idx) + 1) TIMES4(4 * (idx) + 2) TIMES4(4 * (idx) + 3)
203 #define TIMES4(idx) \
204 ENTRY(4 * (idx)) ENTRY(4 * (idx) + 1) ENTRY(4 * (idx) + 2) ENTRY(4 * (idx) + 3)
205 #define ENTRY(x) [x] = ((x) >= 'a' && (x) <= 'f') ? (x) - ('a' - 10) : \
206 ((x) >= 'A' && (x) <= 'F') ? (x) - ('A' - 10) : \
207 ((x) >= '0' && (x) <= '9') ? (x) - '0' : 0,
208
209 static const uint8_t lut[] = {
210 TIMES256(0)
211 };
212 return lut[x];
213 }
214
215 /*
216 * Function same as strcspn but ignores characters if they are inside a C style comments
217 */
218 static size_t mod_strcspn(const char *string, const char *reject)
219 {
220 int i, j;
221
222 for (i = 0; string && string[i]; i++) {
223 if (string[i] == '/' && string[i+1] == '*') {
224 i += 2;
225 while ( string && string[i] && (string[i] != '*' || string[i+1] != '/') )
226 i++;
227 i++;
228 } else if (string[i] == '/' && string[i+1] == '/') {
229 i += 2;
230 while ( string && string[i] && string[i] != '\n' )
231 i++;
232 } else {
233 for (j = 0; reject && reject[j]; j++) {
234 if (string[i] == reject[j])
235 break;
236 }
237 if (reject && reject[j])
238 break;
239 }
240 }
241 return i;
242 }
243
244 static uint32_t color_string_to_rgba(const char *p, size_t len)
245 {
246 uint32_t ret = 0xFF000000;
247 const ColorEntry *entry;
248 char color_name[100];
249
250 if (*p == '#') {
251 p++;
252 len--;
253 if (len == 3) {
254 ret |= (hex_char_to_number(p[2]) << 4) |
255 (hex_char_to_number(p[1]) << 12) |
256 (hex_char_to_number(p[0]) << 20);
257 } else if (len == 4) {
258 ret = (hex_char_to_number(p[3]) << 4) |
259 (hex_char_to_number(p[2]) << 12) |
260 (hex_char_to_number(p[1]) << 20) |
261 (hex_char_to_number(p[0]) << 28);
262 } else if (len == 6) {
263 ret |= hex_char_to_number(p[5]) |
264 (hex_char_to_number(p[4]) << 4) |
265 (hex_char_to_number(p[3]) << 8) |
266 (hex_char_to_number(p[2]) << 12) |
267 (hex_char_to_number(p[1]) << 16) |
268 (hex_char_to_number(p[0]) << 20);
269 } else if (len == 8) {
270 ret = hex_char_to_number(p[7]) |
271 (hex_char_to_number(p[6]) << 4) |
272 (hex_char_to_number(p[5]) << 8) |
273 (hex_char_to_number(p[4]) << 12) |
274 (hex_char_to_number(p[3]) << 16) |
275 (hex_char_to_number(p[2]) << 20) |
276 (hex_char_to_number(p[1]) << 24) |
277 (hex_char_to_number(p[0]) << 28);
278 }
279 } else {
280 len = FFMIN(len, sizeof(color_name) - 1);
281 strncpy(color_name, p, len);
282 color_name[len] = '\0';
283
284 entry = bsearch(color_name,
285 color_table,
286 FF_ARRAY_ELEMS(color_table),
287 sizeof(ColorEntry),
288 color_table_compare);
289
290 if (!entry)
291 return ret;
292
293 ret = entry->rgb_color;
294 }
295 return ret;
296 }
297
298 static int ascii2index(const uint8_t *cpixel, int cpp)
299 {
300 const uint8_t *p = cpixel;
301 int n = 0, m = 1, i;
302
303 for (i = 0; i < cpp; i++) {
304 if (*p < MIN_ELEMENT || *p > MAX_ELEMENT)
305 return AVERROR_INVALIDDATA;
306 n += (*p++ - MIN_ELEMENT) * m;
307 m *= NB_ELEMENTS;
308 }
309 return n;
310 }
311
312 static int xpm_decode_frame(AVCodecContext *avctx, AVFrame *p,
313 int *got_frame, AVPacket *avpkt)
314 {
315 XPMDecContext *x = avctx->priv_data;
316 const uint8_t *end, *ptr;
317 int ncolors, cpp, ret, i, j;
318 int64_t size;
319 uint32_t *dst;
320 int width, height;
321
322 avctx->pix_fmt = AV_PIX_FMT_BGRA;
323
324 av_fast_padded_malloc(&x->buf, &x->buf_size, avpkt->size);
325 if (!x->buf)
326 return AVERROR(ENOMEM);
327 memcpy(x->buf, avpkt->data, avpkt->size);
328 x->buf[avpkt->size] = 0;
329
330 ptr = x->buf;
331 end = x->buf + avpkt->size;
332 while (end - ptr > 9 && memcmp(ptr, "/* XPM */", 9))
333 ptr++;
334
335 if (end - ptr <= 9) {
336 av_log(avctx, AV_LOG_ERROR, "missing signature\n");
337 return AVERROR_INVALIDDATA;
338 }
339
340 ptr += mod_strcspn(ptr, "\"");
341 if (sscanf(ptr, "\"%u %u %u %u\",",
342 &width, &height, &ncolors, &cpp) != 4) {
343 av_log(avctx, AV_LOG_ERROR, "missing image parameters\n");
344 return AVERROR_INVALIDDATA;
345 }
346
347 if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
348 return ret;
349
350 if (cpp <= 0 || cpp >= 5) {
351 av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of chars per pixel: %d\n", cpp);
352 return AVERROR_INVALIDDATA;
353 }
354
355 size = 1;
356 for (i = 0; i < cpp; i++)
357 size *= NB_ELEMENTS;
358
359 if (ncolors <= 0 || ncolors > size) {
360 av_log(avctx, AV_LOG_ERROR, "invalid number of colors: %d\n", ncolors);
361 return AVERROR_INVALIDDATA;
362 }
363
364 if (size > SIZE_MAX / 4)
365 return AVERROR(ENOMEM);
366
367 size *= 4;
368
369 ptr += mod_strcspn(ptr, ",") + 1;
370 if (end - ptr < 1)
371 return AVERROR_INVALIDDATA;
372
373 if (avctx->skip_frame >= AVDISCARD_ALL)
374 return avpkt->size;
375
376 if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
377 return ret;
378
379 av_fast_padded_malloc(&x->pixels, &x->pixels_size, size);
380 if (!x->pixels)
381 return AVERROR(ENOMEM);
382
383 for (i = 0; i < ncolors; i++) {
384 const uint8_t *index;
385 size_t len;
386
387 ptr += mod_strcspn(ptr, "\"") + 1;
388 if (end - ptr < cpp)
389 return AVERROR_INVALIDDATA;
390 index = ptr;
391 ptr += cpp;
392
393 ptr = strstr(ptr, "c ");
394 if (ptr) {
395 ptr += 2;
396 } else {
397 return AVERROR_INVALIDDATA;
398 }
399
400 len = strcspn(ptr, "\" ");
401
402 if ((ret = ascii2index(index, cpp)) < 0)
403 return ret;
404
405 x->pixels[ret] = color_string_to_rgba(ptr, len);
406 ptr += mod_strcspn(ptr, ",") + 1;
407 if (end - ptr < 1)
408 return AVERROR_INVALIDDATA;
409 }
410
411 for (i = 0; i < avctx->height; i++) {
412 dst = (uint32_t *)(p->data[0] + i * p->linesize[0]);
413 if (end - ptr < 1)
414 return AVERROR_INVALIDDATA;
415 ptr += mod_strcspn(ptr, "\"") + 1;
416 if (end - ptr < 1)
417 return AVERROR_INVALIDDATA;
418
419 for (j = 0; j < avctx->width; j++) {
420 if (end - ptr < cpp)
421 return AVERROR_INVALIDDATA;
422
423 if ((ret = ascii2index(ptr, cpp)) < 0)
424 return ret;
425
426 *dst++ = x->pixels[ret];
427 ptr += cpp;
428 }
429 ptr += mod_strcspn(ptr, ",") + 1;
430 }
431
432 *got_frame = 1;
433
434 return avpkt->size;
435 }
436
437 static av_cold int xpm_decode_close(AVCodecContext *avctx)
438 {
439 XPMDecContext *x = avctx->priv_data;
440 av_freep(&x->pixels);
441
442 av_freep(&x->buf);
443 x->buf_size = 0;
444
445 return 0;
446 }
447
448 const FFCodec ff_xpm_decoder = {
449 .p.name = "xpm",
450 CODEC_LONG_NAME("XPM (X PixMap) image"),
451 .p.type = AVMEDIA_TYPE_VIDEO,
452 .p.id = AV_CODEC_ID_XPM,
453 .p.capabilities = AV_CODEC_CAP_DR1,
454 .priv_data_size = sizeof(XPMDecContext),
455 .close = xpm_decode_close,
456 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
457 FF_CODEC_DECODE_CB(xpm_decode_frame),
458 };
459

扁导体发炎吃什么药 五更泻吃什么药 顶天立地是什么意思 量程是什么 活动性肺结核是什么意思
葡萄球菌是什么 iwc是什么牌子手表 百里挑一是什么生肖 月经为什么叫大姨妈 宫腔线不清晰什么意思
为什么老是便秘 什么是精液 阳性是什么病 什么东西补血最快 猫爱吃什么
爆裂性骨折什么意思 令坦是对方什么人的尊称 没有精液是什么原因 骆驼奶有什么功效 心电图逆钟向转位什么意思
老子是什么朝代的人hcv7jop7ns0r.cn 智齿为什么会长出来hcv9jop8ns2r.cn 氨咖黄敏胶囊主治什么hcv8jop8ns6r.cn 带状疱疹用什么药膏hcv7jop7ns3r.cn 舌头白色的是什么原因hcv7jop9ns3r.cn
胚发育成什么hcv9jop1ns4r.cn 国安局是干什么的hcv9jop0ns4r.cn 外阴痒用什么药膏hcv7jop6ns3r.cn 什么水什么山hcv8jop7ns5r.cn 肚子长痘痘是什么原因hcv8jop9ns3r.cn
血压压差小是什么原因mmeoe.com 熊猫长什么样hcv8jop7ns3r.cn 白细胞偏高是什么原因引起的hcv8jop9ns6r.cn 大头鱼吃什么食物hcv8jop0ns5r.cn 吃什么排铅hcv9jop3ns6r.cn
到底为什么hcv9jop3ns0r.cn 在农村干什么挣钱cj623037.com 焦虑症是什么原因引起的onlinewuye.com 三代试管是什么意思hcv8jop5ns3r.cn 面部发红是什么原因hcv8jop5ns8r.cn
百度