]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/targaenc.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavcodec / targaenc.c
index 72d27dce15b364f8fe547ba943d14396f55b64d9..21747bb3687ca959e0c8d6e75e23db28c8133a87 100644 (file)
  * You should have received a copy of the GNU Lesser General Public
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
  */
+
+#include "libavutil/intreadwrite.h"
 #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
@@ -41,7 +46,7 @@ static int targa_encode_rle(uint8_t *outbuf, int out_size, AVFrame *pic,
     out = outbuf;
 
     for(y = 0; y < h; y ++) {
-        ret = ff_rle_encode(out, out_size, pic->data[0] + pic->linesize[0] * y, bpp, w, 0x7f, 0);
+        ret = ff_rle_encode(out, out_size, pic->data[0] + pic->linesize[0] * y, bpp, w, 0x7f, 0, -1, 0);
         if(ret == -1){
             return -1;
         }
@@ -88,7 +93,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 */
@@ -134,8 +139,14 @@ static int targa_encode_frame(AVCodecContext *avctx,
     return out + 26 - outbuf;
 }
 
-static int targa_encode_init(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;
 }
 
@@ -143,8 +154,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},
+    .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"),
 };