荔枝什么季节成熟| 浅卡其色裤子配什么颜色上衣| 做月子要注意什么| sdh是什么意思| 身上湿气重吃什么药| 医学上ca是什么意思| 乔迁之喜送什么| 嘴巴下面长痘痘是什么原因| 骑马标志是什么牌子| 政协是什么| 腰花是什么| 自制力是什么意思| 开什么店好赚钱| 什么汤| 不等闲是什么意思| 植物油是什么油| 宝珀手表属于什么档次| 巴郎子是什么意思| 一见什么| 长期是什么意思| 右手小拇指发麻是什么原因| 拉稀拉水吃什么药管用| 乙酸是什么| 减肥平台期什么意思| 空调健康模式是什么意思| 灵魂契合是什么意思| 宫颈肥大有什么危害| 岫玉是什么| 鸭吃什么食物| 清纯是什么意思| 低密度脂蛋白偏高吃什么药| 症候群什么意思| 杳冥是什么意思| 18k金是什么| 平板电脑与笔记本电脑有什么区别| 木屐是什么意思| drgs付费是什么意思| 什么叫闺蜜| 耳舌念什么| 曷是什么意思| 例假发黑是什么原因| 攒肚是什么意思| pumpkin是什么意思| 吊瓜是什么瓜| mva是什么单位| 吃了牛肉不能吃什么| 耳膜炎是什么原因引起的| 顿服是什么意思| 青霉素主治什么病| 冠脉壁钙化是什么意思| 西洋参补什么| 穿什么衣服| 蝌蚪吃什么食物| 丈二和尚摸不着头脑是什么意思| 老是口干舌燥是什么原因| 天行健下一句是什么| crp高是什么感染| 冠状沟有溃疡是什么病| 佐助是什么意思| 骨质增生吃什么药效果好| 腺管瘤是什么| 胃糜烂吃什么药可以根治| 心律不齐房颤吃什么药| 春天的雨是什么| 冥界是什么意思| 虾和什么相克| 今年22岁属什么生肖| 什么什么和谐| 立秋日有什么禁忌| 腋下有异味用什么药| 什么茶叶好喝| 水浒是什么意思| 塑料五行属什么| 梦到老鼠是什么意思| acg文化是什么意思| 东坡肉是什么菜系| 栀子花什么季节开花| 中位数什么意思| 左心室肥大是什么意思| 梦见手机失而复得是什么意思| 脾胃虚弱吃什么药| 三什么开泰| 尿道感染流脓吃什么药| 泡是什么意思| 硝酸咪康唑乳膏和酮康唑乳膏有什么区别| 心腹是什么意思| 梦到装修房子是什么征兆| 什么的大圆盘| 渗液是什么意思| 1999年属什么生肖| 九月3日是什么日子| 血粘稠吃什么药最好| 特需病房是什么意思| 什么动物倒着走| 龋齿是什么意思| 低血压吃什么调理| 错构瘤是什么| 人走了说什么安慰的话| 嘴唇变厚是什么原因| 黑洞是什么| 紫外线是什么| 五石散是什么| 另煎兑服是什么意思| 萎了是什么意思| 吹水是什么意思| 产褥热是什么病| cot是什么| 田七煲汤配什么材料| 桑葚是什么季节的| 1957年属什么生肖| 小三阳和大三阳有什么区别| 腔梗是什么| 吝啬鬼是什么生肖| 为什么左手会发麻| 脑供血不足吃什么药效果最好| 什么东西不能带上飞机| 频繁是什么意思| sayno是什么意思| 杏黄是什么颜色| 6月份什么星座| 浮木是什么意思| 喉咙肿痛吃什么药好| zoe是什么意思| dmp是什么意思| 查五行缺什么| 梦见给别人钱是什么意思| 牙龈上火吃什么药| 79属什么生肖| 什么粉底液最好用| 哈哈是什么意思| 遗精是什么原因| 春光乍泄是什么意思| 孕妇尿酸高是什么原因| 榴莲的寓意是什么意思| 出油多是什么原因| 什么原因导致宫外孕| 肝硬化挂什么科| 吃什么水果会变白| 三斤八两什么意思| 从什么不什么四字词语| 肠胃炎能吃什么| 女生排卵期是什么时候| 乙亥五行属什么| 撕裂是什么意思| 阴茎溃疡用什么药| 会车是什么意思| 遁入空门是什么意思| 11月18日什么星座| 入户口需要什么资料| 开火车是什么意思| 毕是什么意思| 腺病毒是什么病毒| 乙肝五项145阳性是什么意思| 玉树临风是什么意思| 症瘕痞块是什么意思| 左侧卵巢显示不清是什么意思| c3是什么驾驶证| 容祖儿老公叫什么名字| 什么东西能让皮肤变白| 软化血管吃什么药| 脊髓空洞症吃什么药| 孔雀的尾巴像什么| 梦见打人是什么意思| joeone是什么牌子| 月可以加什么偏旁| 上上签什么意思| 吃茶叶蛋有什么好处和坏处| 客厅沙发后面墙上挂什么画好| 长时间手淫有什么危害| 肝火旺是什么意思| 摇呼啦圈有什么好处| 锁骨下面的骨头叫什么| 纷至沓来是什么意思| 氧化钙是什么| 海藻面膜有什么作用| 头上戴冠是什么生肖| 胃疼想吐是什么原因| 魔怔什么意思| 甲功三项是什么| 猪肉排酸是什么意思| 睾丸痒是什么原因| 强心剂是什么药| 柠檬水苦是什么原因| k粉是什么| 前列腺液是什么东西| 5月24日什么星座| 头孢有什么用| 法是什么| 什么是鸡胸病症状图片| 性功能减退吃什么药| 榴莲有什么营养| 尿液发白是什么原因| 苦瓜泡酒有什么功效和作用| 嗤笑什么意思| 一什么湖面| 鹿茸是鹿的什么部位| 洁字五行属什么| 肌酐激酶高是什么原因| 黄色裤子搭配什么颜色上衣| 什么叫双向情感障碍| 吃什么补锌| 急性肠胃炎是什么引起的| 为什么吃鸽子刀口长得快| 总胆红素高是怎么回事有什么危害| 睾丸扭转有什么症状| 用酒擦身体有什么好处| 康乃馨适合送什么人| 什么水果可以减肥刮油脂| 夏朝前面是什么朝代| 皮下出血点是什么原因| 甲鱼喜欢吃什么| 为什么说成也萧何败也萧何| 在家做什么赚钱| 3月5日是什么星座| 乙肝检查挂什么科| 长孙皇后为什么叫观音婢| 老年人脚肿什么原因| 外出是什么意思| 什么是绝对值| 什么水最解渴| 月经淋漓不尽吃什么药| 空调外机很响是什么原因| 吃菱角有什么好处| 午夜是什么意思| 球拍状胎盘是什么意思| senda是什么牌子| 爷爷和孙子是什么关系| 内痔用什么药| 经常心慌是什么原因| 口臭用什么牙膏| 老人嗜睡是什么征兆| 韧带拉伤有什么症状| 见龙在田什么意思| a是什么| 夜里咳嗽是什么原因| 有趣是什么意思| 什么车可以闯红灯| 子宫出血是什么原因| 什么的果子| 武则天为什么立无字碑| 周期性是什么意思| 怡五行属性是什么| 冠心病吃什么药好| 坐月子吃什么下奶最快最多最有效| 土地出让金是什么意思| 脸上出油多是什么原因| 嗓子痒干咳吃什么药| 黑咖啡为什么能减肥| 刘少奇属什么生肖| 高兴的动物是什么生肖| 黄金微针是什么| 屠苏酒是什么酒| 脚趾痒是什么原因| 胸ct和肺ct有什么区别| 现在开什么实体店赚钱| 尔尔是什么意思| 吃什么可以去脂肪肝| 毛脚女婿是什么意思| 什么是牙齿根管治疗| 11.22什么星座| 皋读什么| 听调不听宣什么意思| 耳机降噪是什么意思| 肺火旺吃什么药最有效| 百度

泉州启用重点车辆监管平台 人车分离违法记录跟人走


Directory: ../../../ffmpeg/
File: src/libavcodec/psd.c
Date: 2025-08-04 11:35:17
Exec Total Coverage
Lines: 164 319 51.4%
Functions: 3 3 100.0%
Branches: 99 180 55.0%

Line Branch Exec Source
1 /*
2 * Photoshop (PSD) image decoder
3 * Copyright (c) 2016 Jokyo Images
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 #include "libavutil/mem.h"
23 #include "bytestream.h"
24 #include "codec_internal.h"
25 #include "decode.h"
26
27 enum PsdCompr {
28 PSD_RAW,
29 PSD_RLE,
30 PSD_ZIP_WITHOUT_P,
31 PSD_ZIP_WITH_P,
32 };
33
34 enum PsdColorMode {
35 PSD_BITMAP,
36 PSD_GRAYSCALE,
37 PSD_INDEXED,
38 PSD_RGB,
39 PSD_CMYK,
40 PSD_MULTICHANNEL,
41 PSD_DUOTONE,
42 PSD_LAB,
43 };
44
45 typedef struct PSDContext {
46 AVClass *class;
47 AVFrame *picture;
48 AVCodecContext *avctx;
49 GetByteContext gb;
50
51 uint8_t * tmp;
52
53 uint16_t channel_count;
54 uint16_t channel_depth;
55
56 uint64_t uncompressed_size;
57 unsigned int pixel_size;/* 1 for 8 bits, 2 for 16 bits */
58 uint64_t line_size;/* length of src data (even width) */
59
60 int width;
61 int height;
62
63 enum PsdCompr compression;
64 enum PsdColorMode color_mode;
65
66 uint8_t palette[AVPALETTE_SIZE];
67 } PSDContext;
68
69 30 static int decode_header(PSDContext * s)
70 {
71 int signature, version, color_mode;
72 int64_t len_section;
73 30 int ret = 0;
74
75
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (bytestream2_get_bytes_left(&s->gb) < 30) {/* File header section + color map data section length */
76 av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
77 return AVERROR_INVALIDDATA;
78 }
79
80 30 signature = bytestream2_get_le32(&s->gb);
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (signature != MKTAG('8','B','P','S')) {
82 av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n", signature);
83 return AVERROR_INVALIDDATA;
84 }
85
86 30 version = bytestream2_get_be16(&s->gb);
87
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (version != 1) {
88 av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
89 return AVERROR_INVALIDDATA;
90 }
91
92 30 bytestream2_skip(&s->gb, 6);/* reserved */
93
94 30 s->channel_count = bytestream2_get_be16(&s->gb);
95
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 if ((s->channel_count < 1) || (s->channel_count > 56)) {
96 av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n", s->channel_count);
97 return AVERROR_INVALIDDATA;
98 }
99
100 30 s->height = bytestream2_get_be32(&s->gb);
101
102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ((s->height > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
103 av_log(s->avctx, AV_LOG_ERROR,
104 "Height > 30000 is experimental, add "
105 "'-strict %d' if you want to try to decode the picture.\n",
106 FF_COMPLIANCE_EXPERIMENTAL);
107 return AVERROR_EXPERIMENTAL;
108 }
109
110 30 s->width = bytestream2_get_be32(&s->gb);
111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ((s->width > 30000) && (s->avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)) {
112 av_log(s->avctx, AV_LOG_ERROR,
113 "Width > 30000 is experimental, add "
114 "'-strict %d' if you want to try to decode the picture.\n",
115 FF_COMPLIANCE_EXPERIMENTAL);
116 return AVERROR_EXPERIMENTAL;
117 }
118
119
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
120 return ret;
121
122 30 s->channel_depth = bytestream2_get_be16(&s->gb);
123
124 30 color_mode = bytestream2_get_be16(&s->gb);
125
5/9
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
30 switch (color_mode) {
126 2 case 0:
127 2 s->color_mode = PSD_BITMAP;
128 2 break;
129 8 case 1:
130 8 s->color_mode = PSD_GRAYSCALE;
131 8 break;
132 2 case 2:
133 2 s->color_mode = PSD_INDEXED;
134 2 break;
135 16 case 3:
136 16 s->color_mode = PSD_RGB;
137 16 break;
138 case 4:
139 s->color_mode = PSD_CMYK;
140 break;
141 case 7:
142 s->color_mode = PSD_MULTICHANNEL;
143 break;
144 2 case 8:
145 2 s->color_mode = PSD_DUOTONE;
146 2 break;
147 case 9:
148 s->color_mode = PSD_LAB;
149 break;
150 default:
151 av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", color_mode);
152 return AVERROR_INVALIDDATA;
153 }
154
155 /* color map data */
156 30 len_section = bytestream2_get_be32(&s->gb);
157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (len_section < 0) {
158 av_log(s->avctx, AV_LOG_ERROR, "Negative size for color map data section.\n");
159 return AVERROR_INVALIDDATA;
160 }
161
162
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
163 av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
164 return AVERROR_INVALIDDATA;
165 }
166
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
30 if (len_section) {
167 int i,j;
168 4 memset(s->palette, 0xff, AVPALETTE_SIZE);
169
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 for (j = HAVE_BIGENDIAN; j < 3 + HAVE_BIGENDIAN; j++)
170
4/4
✓ Branch 0 taken 1050 times.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 2580 times.
✓ Branch 3 taken 12 times.
2592 for (i = 0; i < FFMIN(256, len_section / 3); i++)
171 2580 s->palette[i * 4 + (HAVE_BIGENDIAN ? j : 2 - j)] = bytestream2_get_byteu(&s->gb);
172 4 len_section -= i * 3;
173 }
174 30 bytestream2_skip(&s->gb, len_section);
175
176 /* image resources */
177 30 len_section = bytestream2_get_be32(&s->gb);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (len_section < 0) {
179 av_log(s->avctx, AV_LOG_ERROR, "Negative size for image resources section.\n");
180 return AVERROR_INVALIDDATA;
181 }
182
183
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (bytestream2_get_bytes_left(&s->gb) < (len_section + 4)) { /* section and len next section */
184 av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
185 return AVERROR_INVALIDDATA;
186 }
187 30 bytestream2_skip(&s->gb, len_section);
188
189 /* layers and masks */
190 30 len_section = bytestream2_get_be32(&s->gb);
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (len_section < 0) {
192 av_log(s->avctx, AV_LOG_ERROR, "Negative size for layers and masks data section.\n");
193 return AVERROR_INVALIDDATA;
194 }
195
196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (bytestream2_get_bytes_left(&s->gb) < len_section) {
197 av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
198 return AVERROR_INVALIDDATA;
199 }
200 30 bytestream2_skip(&s->gb, len_section);
201
202 /* image section */
203
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if (bytestream2_get_bytes_left(&s->gb) < 2) {
204 av_log(s->avctx, AV_LOG_ERROR, "File without image data section.\n");
205 return AVERROR_INVALIDDATA;
206 }
207
208 30 s->compression = bytestream2_get_be16(&s->gb);
209
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 switch (s->compression) {
210 30 case 0:
211 case 1:
212 30 break;
213 case 2:
214 avpriv_request_sample(s->avctx, "ZIP without predictor compression");
215 return AVERROR_PATCHWELCOME;
216 case 3:
217 avpriv_request_sample(s->avctx, "ZIP with predictor compression");
218 return AVERROR_PATCHWELCOME;
219 default:
220 av_log(s->avctx, AV_LOG_ERROR, "Unknown compression %d.\n", s->compression);
221 return AVERROR_INVALIDDATA;
222 }
223
224 30 return ret;
225 }
226
227 8 static int decode_rle(PSDContext * s){
228 unsigned int scanline_count;
229 unsigned int sl, count;
230 8 unsigned long target_index = 0;
231 unsigned int p;
232 int8_t rle_char;
233 unsigned int repeat_count;
234 uint8_t v;
235
236 8 scanline_count = s->height * s->channel_count;
237
238 /* scanline table */
239
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (bytestream2_get_bytes_left(&s->gb) < scanline_count * 2) {
240 av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline table.\n");
241 return AVERROR_INVALIDDATA;
242 }
243 8 bytestream2_skip(&s->gb, scanline_count * 2);/* size of each scanline */
244
245 /* decode rle data scanline by scanline */
246
2/2
✓ Branch 0 taken 2804 times.
✓ Branch 1 taken 8 times.
2812 for (sl = 0; sl < scanline_count; sl++) {
247 2804 count = 0;
248
249
2/2
✓ Branch 0 taken 18540 times.
✓ Branch 1 taken 2804 times.
21344 while (count < s->line_size) {
250 18540 rle_char = bytestream2_get_byte(&s->gb);
251
252
2/2
✓ Branch 0 taken 12340 times.
✓ Branch 1 taken 6200 times.
18540 if (rle_char <= 0) {/* byte repeat */
253 12340 repeat_count = rle_char * -1;
254
255
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12340 times.
12340 if (bytestream2_get_bytes_left(&s->gb) < 1) {
256 av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline.\n");
257 return AVERROR_INVALIDDATA;
258 }
259
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12340 times.
12340 if (target_index + repeat_count >= s->uncompressed_size) {
261 av_log(s->avctx, AV_LOG_ERROR, "Invalid rle char.\n");
262 return AVERROR_INVALIDDATA;
263 }
264
265 12340 v = bytestream2_get_byte(&s->gb);
266
2/2
✓ Branch 0 taken 210352 times.
✓ Branch 1 taken 12340 times.
222692 for (p = 0; p <= repeat_count; p++) {
267 210352 s->tmp[target_index++] = v;
268 }
269 12340 count += repeat_count + 1;
270 } else {
271
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6200 times.
6200 if (bytestream2_get_bytes_left(&s->gb) < rle_char) {
272 av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle scanline.\n");
273 return AVERROR_INVALIDDATA;
274 }
275
276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
6200 if (target_index + rle_char >= s->uncompressed_size) {
277 av_log(s->avctx, AV_LOG_ERROR, "Invalid rle char.\n");
278 return AVERROR_INVALIDDATA;
279 }
280
281
2/2
✓ Branch 0 taken 243810 times.
✓ Branch 1 taken 6200 times.
250010 for (p = 0; p <= rle_char; p++) {
282 243810 v = bytestream2_get_byte(&s->gb);
283 243810 s->tmp[target_index++] = v;
284 }
285 6200 count += rle_char + 1;
286 }
287 }
288 }
289
290 8 return 0;
291 }
292
293 30 static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
294 int *got_frame, AVPacket *avpkt)
295 {
296 int ret;
297 uint8_t *ptr;
298 const uint8_t *ptr_data;
299 int index_out, c, y, x, p;
300 30 uint8_t eq_channel[4] = {2,0,1,3};/* RGBA -> GBRA channel order */
301 uint8_t plane_number;
302
303 30 PSDContext *s = avctx->priv_data;
304 30 s->avctx = avctx;
305 30 s->channel_count = 0;
306 30 s->channel_depth = 0;
307 30 s->tmp = NULL;
308 30 s->line_size = 0;
309
310 30 bytestream2_init(&s->gb, avpkt->data, avpkt->size);
311
312
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if ((ret = decode_header(s)) < 0)
313 return ret;
314
315 30 s->pixel_size = s->channel_depth >> 3;/* in byte */
316 30 s->line_size = s->width * s->pixel_size;
317
318
5/7
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
30 switch (s->color_mode) {
319 2 case PSD_BITMAP:
320
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (s->channel_depth != 1 || s->channel_count != 1) {
321 av_log(s->avctx, AV_LOG_ERROR,
322 "Invalid bitmap file (channel_depth %d, channel_count %d)\n",
323 s->channel_depth, s->channel_count);
324 return AVERROR_INVALIDDATA;
325 }
326 2 s->line_size = s->width + 7 >> 3;
327 2 avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
328 2 break;
329 2 case PSD_INDEXED:
330
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (s->channel_depth != 8 || s->channel_count != 1) {
331 av_log(s->avctx, AV_LOG_ERROR,
332 "Invalid indexed file (channel_depth %d, channel_count %d)\n",
333 s->channel_depth, s->channel_count);
334 return AVERROR_INVALIDDATA;
335 }
336 2 avctx->pix_fmt = AV_PIX_FMT_PAL8;
337 2 break;
338 case PSD_CMYK:
339 if (s->channel_count == 4) {
340 if (s->channel_depth == 8) {
341 avctx->pix_fmt = AV_PIX_FMT_GBRP;
342 } else if (s->channel_depth == 16) {
343 avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
344 } else {
345 avpriv_report_missing_feature(avctx, "channel depth %d for cmyk", s->channel_depth);
346 return AVERROR_PATCHWELCOME;
347 }
348 } else if (s->channel_count == 5) {
349 if (s->channel_depth == 8) {
350 avctx->pix_fmt = AV_PIX_FMT_GBRAP;
351 } else if (s->channel_depth == 16) {
352 avctx->pix_fmt = AV_PIX_FMT_GBRAP16BE;
353 } else {
354 avpriv_report_missing_feature(avctx, "channel depth %d for cmyk", s->channel_depth);
355 return AVERROR_PATCHWELCOME;
356 }
357 } else {
358 avpriv_report_missing_feature(avctx, "channel count %d for cmyk", s->channel_count);
359 return AVERROR_PATCHWELCOME;
360 }
361 break;
362 16 case PSD_RGB:
363
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6 times.
16 if (s->channel_count == 3) {
364
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (s->channel_depth == 8) {
365 6 avctx->pix_fmt = AV_PIX_FMT_GBRP;
366
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 } else if (s->channel_depth == 16) {
367 4 avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
368 } else {
369 avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
370 return AVERROR_PATCHWELCOME;
371 }
372
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 } else if (s->channel_count == 4) {
373
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (s->channel_depth == 8) {
374 4 avctx->pix_fmt = AV_PIX_FMT_GBRAP;
375
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 } else if (s->channel_depth == 16) {
376 2 avctx->pix_fmt = AV_PIX_FMT_GBRAP16BE;
377 } else {
378 avpriv_report_missing_feature(avctx, "channel depth %d for rgb", s->channel_depth);
379 return AVERROR_PATCHWELCOME;
380 }
381 } else {
382 avpriv_report_missing_feature(avctx, "channel count %d for rgb", s->channel_count);
383 return AVERROR_PATCHWELCOME;
384 }
385 16 break;
386 2 case PSD_DUOTONE:
387 2 av_log(avctx, AV_LOG_WARNING, "ignoring unknown duotone specification.\n");
388 10 case PSD_GRAYSCALE:
389
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (s->channel_count == 1) {
390
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (s->channel_depth == 8) {
391 4 avctx->pix_fmt = AV_PIX_FMT_GRAY8;
392
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 } else if (s->channel_depth == 16) {
393 2 avctx->pix_fmt = AV_PIX_FMT_GRAY16BE;
394 } else if (s->channel_depth == 32) {
395 avctx->pix_fmt = AV_PIX_FMT_GRAYF32BE;
396 } else {
397 avpriv_report_missing_feature(avctx, "channel depth %d for grayscale", s->channel_depth);
398 return AVERROR_PATCHWELCOME;
399 }
400
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 } else if (s->channel_count == 2) {
401
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (s->channel_depth == 8) {
402 2 avctx->pix_fmt = AV_PIX_FMT_YA8;
403
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 } else if (s->channel_depth == 16) {
404 2 avctx->pix_fmt = AV_PIX_FMT_YA16BE;
405 } else {
406 avpriv_report_missing_feature(avctx, "channel depth %d for grayscale", s->channel_depth);
407 return AVERROR_PATCHWELCOME;
408 }
409 } else {
410 avpriv_report_missing_feature(avctx, "channel count %d for grayscale", s->channel_count);
411 return AVERROR_PATCHWELCOME;
412 }
413 10 break;
414 default:
415 avpriv_report_missing_feature(avctx, "color mode %d", s->color_mode);
416 return AVERROR_PATCHWELCOME;
417 }
418
419 30 s->uncompressed_size = s->line_size * s->height * s->channel_count;
420
421 /* decode picture if need */
422
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22 times.
30 if (s->compression == PSD_RLE) {
423 8 s->tmp = av_malloc(s->uncompressed_size);
424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (!s->tmp)
425 return AVERROR(ENOMEM);
426
427 8 ret = decode_rle(s);
428
429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (ret < 0) {
430 av_freep(&s->tmp);
431 return ret;
432 }
433
434 8 ptr_data = s->tmp;
435 } else {
436
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
22 if (bytestream2_get_bytes_left(&s->gb) < s->uncompressed_size) {
437 av_log(s->avctx, AV_LOG_ERROR, "Not enough data for raw image data section.\n");
438 return AVERROR_INVALIDDATA;
439 }
440 22 ptr_data = s->gb.buffer;
441 }
442
443
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
30 if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
444 return ret;
445
446 /* Store data */
447
4/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 26 times.
30 if ((avctx->pix_fmt == AV_PIX_FMT_YA8)||(avctx->pix_fmt == AV_PIX_FMT_YA16BE)){/* Interleaved */
448 4 ptr = picture->data[0];
449
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 for (c = 0; c < s->channel_count; c++) {
450
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for (y = 0; y < s->height; y++) {
451
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 1024 times.
132096 for (x = 0; x < s->width; x++) {
452 131072 index_out = y * picture->linesize[0] + x * s->channel_count * s->pixel_size + c * s->pixel_size;
453
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 131072 times.
327680 for (p = 0; p < s->pixel_size; p++) {
454 196608 ptr[index_out + p] = *ptr_data;
455 196608 ptr_data ++;
456 }
457 }
458 }
459 }
460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 } else if (s->color_mode == PSD_CMYK) {
461 uint8_t *dst[4] = { picture->data[0], picture->data[1], picture->data[2], picture->data[3] };
462 const uint8_t *src[5] = { ptr_data };
463 src[1] = src[0] + s->line_size * s->height;
464 src[2] = src[1] + s->line_size * s->height;
465 src[3] = src[2] + s->line_size * s->height;
466 src[4] = src[3] + s->line_size * s->height;
467 if (s->channel_depth == 8) {
468 for (y = 0; y < s->height; y++) {
469 for (x = 0; x < s->width; x++) {
470 int k = src[3][x];
471 int r = src[0][x] * k;
472 int g = src[1][x] * k;
473 int b = src[2][x] * k;
474 dst[0][x] = g * 257 >> 16;
475 dst[1][x] = b * 257 >> 16;
476 dst[2][x] = r * 257 >> 16;
477 }
478 dst[0] += picture->linesize[0];
479 dst[1] += picture->linesize[1];
480 dst[2] += picture->linesize[2];
481 src[0] += s->line_size;
482 src[1] += s->line_size;
483 src[2] += s->line_size;
484 src[3] += s->line_size;
485 }
486 if (avctx->pix_fmt == AV_PIX_FMT_GBRAP) {
487 for (y = 0; y < s->height; y++) {
488 memcpy(dst[3], src[4], s->line_size);
489 src[4] += s->line_size;
490 dst[3] += picture->linesize[3];
491 }
492 }
493 } else {
494 for (y = 0; y < s->height; y++) {
495 for (x = 0; x < s->width; x++) {
496 int64_t k = AV_RB16(&src[3][x * 2]);
497 int64_t r = AV_RB16(&src[0][x * 2]) * k;
498 int64_t g = AV_RB16(&src[1][x * 2]) * k;
499 int64_t b = AV_RB16(&src[2][x * 2]) * k;
500 AV_WB16(&dst[0][x * 2], g * 65537 >> 32);
501 AV_WB16(&dst[1][x * 2], b * 65537 >> 32);
502 AV_WB16(&dst[2][x * 2], r * 65537 >> 32);
503 }
504 dst[0] += picture->linesize[0];
505 dst[1] += picture->linesize[1];
506 dst[2] += picture->linesize[2];
507 src[0] += s->line_size;
508 src[1] += s->line_size;
509 src[2] += s->line_size;
510 src[3] += s->line_size;
511 }
512 if (avctx->pix_fmt == AV_PIX_FMT_GBRAP16BE) {
513 for (y = 0; y < s->height; y++) {
514 memcpy(dst[3], src[4], s->line_size);
515 src[4] += s->line_size;
516 dst[3] += picture->linesize[3];
517 }
518 }
519 }
520 } else {/* Planar */
521
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16 times.
26 if (s->channel_count == 1)/* gray 8 or gray 16be */
522 10 eq_channel[0] = 0;/* assign first channel, to first plane */
523
524
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 26 times.
90 for (c = 0; c < s->channel_count; c++) {
525 64 plane_number = eq_channel[c];
526 64 ptr = picture->data[plane_number];/* get the right plane */
527
2/2
✓ Branch 0 taken 8174 times.
✓ Branch 1 taken 64 times.
8238 for (y = 0; y < s->height; y++) {
528 8174 memcpy(ptr, ptr_data, s->line_size);
529 8174 ptr += picture->linesize[plane_number];
530 8174 ptr_data += s->line_size;
531 }
532 }
533 }
534
535
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
30 if (s->color_mode == PSD_INDEXED) {
536 2 memcpy(picture->data[1], s->palette, AVPALETTE_SIZE);
537 }
538
539 30 av_freep(&s->tmp);
540
541 30 picture->pict_type = AV_PICTURE_TYPE_I;
542 30 *got_frame = 1;
543
544 30 return avpkt->size;
545 }
546
547 const FFCodec ff_psd_decoder = {
548 .p.name = "psd",
549 CODEC_LONG_NAME("Photoshop PSD file"),
550 .p.type = AVMEDIA_TYPE_VIDEO,
551 .p.id = AV_CODEC_ID_PSD,
552 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
553 .priv_data_size = sizeof(PSDContext),
554 FF_CODEC_DECODE_CB(decode_frame),
555 };
556

女人更年期有什么症状 健身吃什么 小肚子胀是什么原因女性 病毒性咳嗽吃什么药好 667什么意思
为什么不能下午看病人 补肾虚吃什么药最好 换什么机油好 4月21日什么星座 口苦是什么问题
社保卡属于什么银行 自来鸟是什么兆头 aj是什么意思 腿疼挂什么科 射精是什么意思
内科检查什么 月经没来吃什么药可以催月经来 甲醛什么气味 平常平时叫什么日 dxm是什么药
睡觉磨牙什么原因hcv8jop9ns6r.cn 预调酒是什么意思hcv8jop3ns3r.cn 妊娠反应什么时候开始bjhyzcsm.com 瑜伽是什么意思mmeoe.com 1.8是什么星座hcv8jop4ns7r.cn
咳嗽有什么特效药hcv7jop9ns9r.cn 什么得直什么hcv8jop8ns4r.cn ups是什么快递公司hcv8jop0ns7r.cn 肾在五行中属什么hcv9jop4ns2r.cn hcv是什么病毒hcv9jop5ns4r.cn
哈喇子是什么意思ff14chat.com 头晕目眩是什么病的征兆hcv9jop1ns4r.cn 脸上出油多是什么原因hcv9jop4ns4r.cn 钾高吃什么可以降下来hcv8jop6ns2r.cn 作息时间是什么意思sanhestory.com
奢侈的近义词是什么hcv8jop0ns9r.cn 宿醉什么意思aiwuzhiyu.com 八月十六号是什么星座hcv8jop2ns9r.cn 什么叫靶向治疗hcv8jop0ns9r.cn 血压低什么原因造成的hcv8jop1ns4r.cn
百度