annotate bmp.c @ 2995:dfc271b90fe6 libavcodec

4mv + iter ME 10l fix (still not bugfree but better)
author michael
date Thu, 29 Dec 2005 02:17:51 +0000
parents ef2149182f1c
children 0b546eab515d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2949
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
1 /*
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
2 * BMP image format
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
3 * Copyright (c) 2005 Mans Rullgard
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
4 *
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
9 *
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
13 * Lesser General Public License for more details.
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
14 *
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
18 */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
19
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
20 #include "avcodec.h"
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
21 #include "bitstream.h"
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
22 #include "bswap.h"
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
23
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
24 typedef struct BMPContext {
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
25 AVFrame picture;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
26 } BMPContext;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
27
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
28 #define BMP_RGB 0
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
29 #define BMP_RLE8 1
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
30 #define BMP_RLE4 2
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
31 #define BMP_BITFIELDS 3
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
32
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
33 #define read16(bits) bswap_16(get_bits(bits, 16))
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
34 #define read32(bits) bswap_32(get_bits_long(bits, 32))
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
35
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
36 static int bmp_decode_init(AVCodecContext *avctx){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
37 BMPContext *s = avctx->priv_data;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
38
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
39 avcodec_get_frame_defaults((AVFrame*)&s->picture);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
40 avctx->coded_frame = (AVFrame*)&s->picture;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
41
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
42 return 0;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
43 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
44
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2949
diff changeset
45 static int bmp_decode_frame(AVCodecContext *avctx,
2949
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
46 void *data, int *data_size,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
47 uint8_t *buf, int buf_size)
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
48 {
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
49 BMPContext *s = avctx->priv_data;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
50 AVFrame *picture = data;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
51 AVFrame *p = &s->picture;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
52 GetBitContext bits;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
53 unsigned int fsize, hsize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
54 int width, height;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
55 unsigned int depth;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
56 unsigned int comp;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
57 unsigned int ihsize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
58 int i, j, n, linesize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
59 uint32_t rgb[3];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
60 uint8_t *ptr;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
61 int dsize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
62
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
63 if(buf_size < 14){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
64 av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
65 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
66 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
67
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
68 init_get_bits(&bits, buf, buf_size);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
69
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
70 if(get_bits(&bits, 16) != 0x424d){ /* 'BM' */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
71 av_log(avctx, AV_LOG_ERROR, "bad magic number\n");
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
72 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
73 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
74
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
75 fsize = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
76 if(buf_size < fsize){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
77 av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
78 buf_size, fsize);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
79 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
80 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
81
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
82 skip_bits(&bits, 16); /* reserved1 */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
83 skip_bits(&bits, 16); /* reserved2 */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
84
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
85 hsize = read32(&bits); /* header size */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
86 if(fsize <= hsize){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
87 av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
88 fsize, hsize);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
89 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
90 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
91
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
92 ihsize = read32(&bits); /* more header size */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
93 if(ihsize + 14 > hsize){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
94 av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
95 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
96 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
97
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
98 width = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
99 height = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
100
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
101 if(read16(&bits) != 1){ /* planes */
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
102 av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
103 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
104 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
105
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
106 depth = read16(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
107
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
108 if(ihsize > 16)
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
109 comp = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
110 else
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
111 comp = BMP_RGB;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
112
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
113 if(comp != BMP_RGB && comp != BMP_BITFIELDS){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
114 av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
115 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
116 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
117
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
118 if(comp == BMP_BITFIELDS){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
119 skip_bits(&bits, 20 * 8);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
120 rgb[0] = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
121 rgb[1] = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
122 rgb[2] = read32(&bits);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
123 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
124
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
125 avctx->codec_id = CODEC_ID_BMP;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
126 avctx->width = width;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
127 avctx->height = height > 0? height: -height;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
128
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
129 avctx->pix_fmt = PIX_FMT_NONE;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
130
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
131 switch(depth){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
132 case 32:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
133 if(comp == BMP_BITFIELDS){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
134 rgb[0] = (rgb[0] >> 15) & 3;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
135 rgb[1] = (rgb[1] >> 15) & 3;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
136 rgb[2] = (rgb[2] >> 15) & 3;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
137
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
138 if(rgb[0] + rgb[1] + rgb[2] != 3 ||
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
139 rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
140 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
141 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
142 } else {
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
143 rgb[0] = 2;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
144 rgb[1] = 1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
145 rgb[2] = 0;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
146 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
147
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
148 avctx->pix_fmt = PIX_FMT_BGR24;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
149 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
150 case 24:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
151 avctx->pix_fmt = PIX_FMT_BGR24;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
152 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
153 case 16:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
154 if(comp == BMP_RGB)
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
155 avctx->pix_fmt = PIX_FMT_RGB555;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
156 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
157 default:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
158 av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
159 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
160 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
161
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
162 if(avctx->pix_fmt == PIX_FMT_NONE){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
163 av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n");
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
164 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
165 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
166
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
167 p->reference = 0;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
168 if(avctx->get_buffer(avctx, p) < 0){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
169 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
170 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
171 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
172 p->pict_type = FF_I_TYPE;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
173 p->key_frame = 1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
174
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
175 buf += hsize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
176 dsize = buf_size - hsize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
177
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
178 n = avctx->width * (depth / 8);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
179
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
180 if(n * avctx->height > dsize){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
181 av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n",
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
182 dsize, n * avctx->height);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
183 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
184 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
185
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
186 if(height > 0){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
187 ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
188 linesize = -p->linesize[0];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
189 } else {
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
190 ptr = p->data[0];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
191 linesize = p->linesize[0];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
192 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
193
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
194 switch(depth){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
195 case 24:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
196 for(i = 0; i < avctx->height; i++){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
197 memcpy(ptr, buf, n);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
198 buf += n;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
199 ptr += linesize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
200 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
201 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
202 case 16:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
203 for(i = 0; i < avctx->height; i++){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
204 uint16_t *src = (uint16_t *) buf;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
205 uint16_t *dst = (uint16_t *) ptr;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
206
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
207 for(j = 0; j < avctx->width; j++)
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
208 *dst++ = le2me_16(*src++);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
209
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
210 buf += n;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
211 ptr += linesize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
212 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
213 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
214 case 32:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
215 for(i = 0; i < avctx->height; i++){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
216 uint8_t *src = buf;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
217 uint8_t *dst = ptr;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
218
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
219 for(j = 0; j < avctx->width; j++){
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
220 dst[0] = src[rgb[2]];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
221 dst[1] = src[rgb[1]];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
222 dst[2] = src[rgb[0]];
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
223 dst += 3;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
224 src += 4;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
225 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
226
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
227 buf += n;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
228 ptr += linesize;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
229 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
230 break;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
231 default:
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
232 av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n");
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
233 return -1;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
234 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
235
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
236 *picture = s->picture;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
237 *data_size = sizeof(AVPicture);
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
238
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
239 return buf_size;
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
240 }
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
241
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
242 AVCodec bmp_decoder = {
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
243 "bmp",
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
244 CODEC_TYPE_VIDEO,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
245 CODEC_ID_BMP,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
246 sizeof(BMPContext),
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
247 bmp_decode_init,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
248 NULL,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
249 NULL,
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
250 bmp_decode_frame
e5a10ae14ffb BMP image decoder
mru
parents:
diff changeset
251 };