comparison targaenc.c @ 10341:e9435ad2d61e libavcodec

Add support for TARGA images without RLE compression. Patch by Anne-Laure de Smit: gmail_address(annelaure, desmit)
author benoit
date Thu, 01 Oct 2009 12:20:08 +0000
parents 38cfe222e1a4
children fc22144efcaf
comparison
equal deleted inserted replaced
10340:5f263438d11b 10341:e9435ad2d61e
74 74
75 static int targa_encode_frame(AVCodecContext *avctx, 75 static int targa_encode_frame(AVCodecContext *avctx,
76 unsigned char *outbuf, 76 unsigned char *outbuf,
77 int buf_size, void *data){ 77 int buf_size, void *data){
78 AVFrame *p = data; 78 AVFrame *p = data;
79 int bpp, picsize, datasize; 79 int bpp, picsize, datasize = -1;
80 uint8_t *out; 80 uint8_t *out;
81 81
82 if(avctx->width > 0xffff || avctx->height > 0xffff) { 82 if(avctx->width > 0xffff || avctx->height > 0xffff) {
83 av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n"); 83 av_log(avctx, AV_LOG_ERROR, "image dimensions too large\n");
84 return -1; 84 return -1;
118 bpp = outbuf[16] >> 3; 118 bpp = outbuf[16] >> 3;
119 119
120 out = outbuf + 18; /* skip past the header we just output */ 120 out = outbuf + 18; /* skip past the header we just output */
121 121
122 /* try RLE compression */ 122 /* try RLE compression */
123 if (avctx->coder_type != FF_CODER_TYPE_RAW)
123 datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height); 124 datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
124 125
125 /* if that worked well, mark the picture as RLE compressed */ 126 /* if that worked well, mark the picture as RLE compressed */
126 if(datasize >= 0) 127 if(datasize >= 0)
127 outbuf[2] |= 8; 128 outbuf[2] |= 8;