[FFmpeg-devel] [PATCH 1/3] Add support for PIX_FMT_RGBA in the targa encoder.

Stefano Sabatini stefano.sabatini-lala
Tue Oct 12 15:23:18 CEST 2010


---
 libavcodec/targaenc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index e5d0042..4eceac7 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -98,7 +98,6 @@ static int targa_encode_frame(AVCodecContext *avctx,
     AV_WL16(outbuf+14, avctx->height);
     outbuf[17] = 0x20;           /* origin is top-left. no alpha */
 
-    /* TODO: support alpha channel */
     switch(avctx->pix_fmt) {
     case PIX_FMT_GRAY8:
         outbuf[2] = 3;           /* uncompressed grayscale image */
@@ -112,6 +111,10 @@ static int targa_encode_frame(AVCodecContext *avctx,
         outbuf[2] = 2;           /* uncompressed true-color image */
         outbuf[16] = 24;         /* bpp */
         break;
+    case PIX_FMT_BGRA:
+        outbuf[2] = 2;           /* uncompressed true-color image */
+        outbuf[16] = 32;         /* bpp */
+        break;
     default:
         return -1;
     }
@@ -158,6 +161,6 @@ AVCodec targa_encoder = {
     .priv_data_size = sizeof(TargaContext),
     .init = targa_encode_init,
     .encode = targa_encode_frame,
-    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555LE, PIX_FMT_GRAY8, PIX_FMT_NONE},
+    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_BGRA, PIX_FMT_RGB555LE, PIX_FMT_GRAY8, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("Truevision Targa image"),
 };
-- 
1.7.1




More information about the ffmpeg-devel mailing list