]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/targaenc.c
DCA: ARM/NEON optimised lfe_fir
[ffmpeg] / libavcodec / targaenc.c
index 90dc8cba617f4a35c0d47594b0e42b21512c107d..e5d0042ecb04229348bda91d1aafb4069601ed45 100644 (file)
  * 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
@@ -70,7 +76,7 @@ static int targa_encode_frame(AVCodecContext *avctx,
                               unsigned char *outbuf,
                               int buf_size, void *data){
     AVFrame *p = data;
-    int bpp, picsize, datasize;
+    int bpp, picsize, datasize = -1;
     uint8_t *out;
 
     if(avctx->width > 0xffff || avctx->height > 0xffff) {
@@ -98,7 +104,7 @@ static int targa_encode_frame(AVCodecContext *avctx,
         outbuf[2] = 3;           /* uncompressed grayscale image */
         outbuf[16] = 8;          /* bpp */
         break;
-    case PIX_FMT_RGB555:
+    case PIX_FMT_RGB555LE:
         outbuf[2] = 2;           /* uncompresses true-color image */
         outbuf[16] = 16;         /* bpp */
         break;
@@ -114,7 +120,8 @@ static int targa_encode_frame(AVCodecContext *avctx,
     out = outbuf + 18;  /* skip past the header we just output */
 
     /* try RLE compression */
-    datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
+    if (avctx->coder_type != FF_CODER_TYPE_RAW)
+        datasize = targa_encode_rle(out, picsize, p, bpp, avctx->width, avctx->height);
 
     /* if that worked well, mark the picture as RLE compressed */
     if(datasize >= 0)
@@ -135,16 +142,22 @@ 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;
 }
 
 AVCodec targa_encoder = {
     .name = "targa",
-    .type = CODEC_TYPE_VIDEO,
+    .type = AVMEDIA_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, PIX_FMT_NONE},
-    .long_name= "Truevision Targa image",
+    .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB555LE, PIX_FMT_GRAY8, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("Truevision Targa image"),
 };