37 void *
data,
int *data_size,
40 const uint8_t *buf = avpkt->
data;
41 int buf_size = avpkt->
size;
45 unsigned int fsize, hsize;
50 int i, j, n, linesize;
54 const uint8_t *buf0 = buf;
62 if(bytestream_get_byte(&buf) !=
'B' ||
63 bytestream_get_byte(&buf) !=
'M') {
68 fsize = bytestream_get_le32(&buf);
78 hsize = bytestream_get_le32(&buf);
79 ihsize = bytestream_get_le32(&buf);
80 if(ihsize + 14 > hsize){
86 if(fsize == 14 || fsize == ihsize + 14)
100 width = bytestream_get_le32(&buf);
101 height = bytestream_get_le32(&buf);
104 width = bytestream_get_le16(&buf);
105 height = bytestream_get_le16(&buf);
112 if(bytestream_get_le16(&buf) != 1){
117 depth = bytestream_get_le16(&buf);
120 comp = bytestream_get_le32(&buf);
131 rgb[0] = bytestream_get_le32(&buf);
132 rgb[1] = bytestream_get_le32(&buf);
133 rgb[2] = bytestream_get_le32(&buf);
144 rgb[0] = (rgb[0] >> 15) & 3;
145 rgb[1] = (rgb[1] >> 15) & 3;
146 rgb[2] = (rgb[2] >> 15) & 3;
148 if(rgb[0] + rgb[1] + rgb[2] != 3 ||
149 rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
167 if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
169 else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
171 else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
174 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
180 if(hsize - ihsize - 14 > 0)
187 if(hsize - ihsize - 14 > 0){
216 dsize = buf_size - hsize;
223 dsize, n * avctx->
height);
240 int colors = 1 <<
depth;
242 memset(p->
data[1], 0, 1024);
247 t = bytestream_get_le32(&buf);
248 if(t < 0 || t > (1 << depth)){
249 av_log(avctx,
AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %d\n", t, depth);
254 buf = buf0 + 14 + ihsize;
255 if((hsize-ihsize-14) < (colors << 2)){
256 for(i = 0; i < colors; i++)
257 ((uint32_t*)p->
data[1])[i] = bytestream_get_le24(&buf);
259 for(i = 0; i < colors; i++)
260 ((uint32_t*)p->
data[1])[i] = bytestream_get_le32(&buf);
278 for (i = 0; i < avctx->
height; i++) {
280 for (j = 0; j < n; j++) {
281 ptr[j*8+0] = buf[j] >> 7;
282 ptr[j*8+1] = (buf[j] >> 6) & 1;
283 ptr[j*8+2] = (buf[j] >> 5) & 1;
284 ptr[j*8+3] = (buf[j] >> 4) & 1;
285 ptr[j*8+4] = (buf[j] >> 3) & 1;
286 ptr[j*8+5] = (buf[j] >> 2) & 1;
287 ptr[j*8+6] = (buf[j] >> 1) & 1;
288 ptr[j*8+7] = buf[j] & 1;
296 for(i = 0; i < avctx->
height; i++){
303 for(i = 0; i < avctx->
height; i++){
305 for(j = 0; j < n; j++){
306 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
307 ptr[j*2+1] = buf[j] & 0xF;
314 for(i = 0; i < avctx->
height; i++){
315 const uint16_t *src = (
const uint16_t *) buf;
316 uint16_t *dst = (uint16_t *) ptr;
318 for(j = 0; j < avctx->
width; j++)
326 for(i = 0; i < avctx->
height; i++){
327 const uint8_t *src = buf;
330 for(j = 0; j < avctx->
width; j++){
331 dst[0] = src[rgb[2]];
332 dst[1] = src[rgb[1]];
333 dst[2] = src[rgb[0]];
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
four components are given, that's all.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int init(AVCodecParserContext *s)
struct BMPContext BMPContext
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
static av_cold int bmp_decode_end(AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
static av_cold int bmp_decode_init(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
struct AVPicture AVPicture
four components are given, that's all.
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
8 bit with PIX_FMT_RGB32 palette
int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
int key_frame
1 -> keyframe, 0-> not
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.