]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/targaenc.c
Simplify rms(): merge a few operations in the same statement
[ffmpeg] / libavcodec / targaenc.c
index 120c62ba703b9bc9ff649ddb04677373c4a513b5..958ae50553928b74edcf278e939aa323bbeccd23 100644 (file)
 #include "avcodec.h"
 #include "rle.h"
 
+typedef struct TargaContext {
+    AVFrame picture;
+} TargaContext;
+
 /**
  * RLE compress the image, with maximum size of out_size
  * @param outbuf Output buffer
@@ -87,7 +91,7 @@ static int targa_encode_frame(AVCodecContext *avctx,
     p->key_frame= 1;
 
     /* zero out the header and only set applicable fields */
-    memset(outbuf, 0, 11);
+    memset(outbuf, 0, 12);
     AV_WL16(outbuf+12, avctx->width);
     AV_WL16(outbuf+14, avctx->height);
     outbuf[17] = 0x20;           /* origin is top-left. no alpha */
@@ -135,6 +139,12 @@ static int targa_encode_frame(AVCodecContext *avctx,
 
 static av_cold int targa_encode_init(AVCodecContext *avctx)
 {
+    TargaContext *s = avctx->priv_data;
+
+    avcodec_get_frame_defaults(&s->picture);
+    s->picture.key_frame= 1;
+    avctx->coded_frame= &s->picture;
+
     return 0;
 }
 
@@ -142,9 +152,9 @@ AVCodec targa_encoder = {
     .name = "targa",
     .type = CODEC_TYPE_VIDEO,
     .id = CODEC_ID_TARGA,
-    .priv_data_size = 0,
+    .priv_data_size = sizeof(TargaContext),
     .init = targa_encode_init,
     .encode = targa_encode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555, PIX_FMT_GRAY8, -1},
-    .long_name= "Truevision Targa image",
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555, PIX_FMT_GRAY8, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("Truevision Targa image"),
 };