comparison gui/util/bitmap.c @ 33112:654dfdf176ac

Revise debug messages. All messages start with [bitmap] and are level MSGL_DBG2 now. The texts have been revised, some messages were added or removed.
author ib
date Mon, 04 Apr 2011 12:01:27 +0000
parents f64d41dac10b
children cc6d4af87b99
comparison
equal deleted inserted replaced
33111:7b7d03089255 33112:654dfdf176ac
39 AVPacket pkt; 39 AVPacket pkt;
40 40
41 fp = fopen(fname, "rb"); 41 fp = fopen(fname, "rb");
42 42
43 if (!fp) { 43 if (!fp) {
44 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] file read error ( %s )\n", fname); 44 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] open error: %s\n", fname);
45 return 1; 45 return 1;
46 } 46 }
47 47
48 fseek(fp, 0, SEEK_END); 48 fseek(fp, 0, SEEK_END);
49 len = ftell(fp); 49 len = ftell(fp);
50 50
51 if (len > 50 * 1024 * 1024) { 51 if (len > 50 * 1024 * 1024) {
52 fclose(fp); 52 fclose(fp);
53 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] file too big: %s\n", fname);
53 return 2; 54 return 2;
54 } 55 }
55 56
56 data = av_malloc(len + FF_INPUT_BUFFER_PADDING_SIZE); 57 data = av_malloc(len + FF_INPUT_BUFFER_PADDING_SIZE);
57 58
108 avcodec_close(avctx); 109 avcodec_close(avctx);
109 av_freep(&frame); 110 av_freep(&frame);
110 av_freep(&avctx); 111 av_freep(&avctx);
111 av_freep(&data); 112 av_freep(&data);
112 113
113 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] filename: %s.\n", fname); 114 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] file: %s\n", fname);
114 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] size: %lux%lu bits: %u\n", bf->Width, bf->Height, bf->BPP); 115 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] size: %lux%lu, color depth: %u\n", bf->Width, bf->Height, bf->BPP);
115 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[png] imagesize: %lu\n", bf->ImageSize); 116 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] image size: %lu\n", bf->ImageSize);
116 117
117 return !(decode_ok && bf->BPP); 118 return !(decode_ok && bf->BPP);
118 } 119 }
119 120
120 static int conv24to32(txSample *bf) 121 static int conv24to32(txSample *bf)
128 bf->ImageSize = bf->Width * bf->Height * 4; 129 bf->ImageSize = bf->Width * bf->Height * 4;
129 bf->Image = calloc(1, bf->ImageSize); 130 bf->Image = calloc(1, bf->ImageSize);
130 131
131 if (!bf->Image) { 132 if (!bf->Image) {
132 free(tmpImage); 133 free(tmpImage);
133 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] not enough memory for image\n"); 134 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] not enough memory: %lu\n", bf->ImageSize);
134 return 1; 135 return 1;
135 } 136 }
137
138 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 32 bpp conversion size: %lu\n", bf->ImageSize);
136 139
137 for (c = 0, i = 0; c < bf->ImageSize; c += 4, i += 3) 140 for (c = 0, i = 0; c < bf->ImageSize; c += 4, i += 3)
138 *(uint32_t *)&bf->Image[c] = AV_RB24(&tmpImage[i]); 141 *(uint32_t *)&bf->Image[c] = AV_RB24(&tmpImage[i]);
139 142
140 free(tmpImage); 143 free(tmpImage);
188 191
189 if (fname == NULL) 192 if (fname == NULL)
190 return -2; 193 return -2;
191 194
192 if (pngRead(fname, bf)) { 195 if (pngRead(fname, bf)) {
193 mp_dbg(MSGT_GPLAYER, MSGL_FATAL, "[bitmap] unknown file type ( %s )\n", fname); 196 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] read error: %s\n", fname);
194 return -5; 197 return -5;
195 } 198 }
196 199
197 if (bf->BPP < 24) { 200 if (bf->BPP < 24) {
198 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n"); 201 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] bpp too low: %u\n", bf->BPP);
199 return -1; 202 return -1;
200 } 203 }
201 204
202 if (conv24to32(bf)) 205 if (conv24to32(bf))
203 return -8; 206 return -8;
217 { 220 {
218 out->Width = in->Width; 221 out->Width = in->Width;
219 out->Height = in->Height; 222 out->Height = in->Height;
220 out->BPP = 1; 223 out->BPP = 1;
221 out->ImageSize = (out->Width * out->Height + 7) / 8; 224 out->ImageSize = (out->Width * out->Height + 7) / 8;
222
223 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[c32to1] imagesize: %lu\n", out->ImageSize);
224 225
225 out->Image = calloc(1, out->ImageSize); 226 out->Image = calloc(1, out->ImageSize);
226 227
227 if (out->Image == NULL) 228 if (out->Image == NULL)
228 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_NotEnoughMemoryC32To1); 229 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_NotEnoughMemoryC32To1);
246 out->Image[c++] = tmp; 247 out->Image[c++] = tmp;
247 tmp = b = 0; 248 tmp = b = 0;
248 } 249 }
249 } 250 }
250 251
252 mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 1 bpp conversion size: %lu\n", out->ImageSize);
253
251 if (b) 254 if (b)
252 out->Image[c] = tmp; 255 out->Image[c] = tmp;
253 256
254 if (nothaveshape) { 257 if (nothaveshape) {
255 free(out->Image); 258 free(out->Image);