summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vd_mtga.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpcodecs/vd_mtga.c')
-rw-r--r--libmpcodecs/vd_mtga.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/libmpcodecs/vd_mtga.c b/libmpcodecs/vd_mtga.c
index 61022c71c8..fb5fa6e807 100644
--- a/libmpcodecs/vd_mtga.c
+++ b/libmpcodecs/vd_mtga.c
@@ -42,10 +42,10 @@ typedef struct
{
unsigned char id_len;
unsigned short img_type;
-
+
unsigned short width;
unsigned short height;
-
+
unsigned char bpp;
unsigned char origin; /* 0 = lower left, 1 = upper left */
unsigned short start_row;
@@ -100,17 +100,17 @@ static void decode_rle_tga(TGAInfo *info, unsigned char *data, mp_image_t *mpi)
for (row = info->start_row; (!info->origin && row) || (info->origin && row < info->height); row += info->increment)
{
final = mpi->planes[0] + mpi->stride[0] * row;
-
+
for (col = 0; col < info->width; col += repetitions)
{
packet_header = *data++;
repetitions = (1 + (packet_header & 0x7f));
replen = repetitions * num_bytes;
-
+
if (packet_header & 0x80) /* runlength encoded packet */
{
memcpy(final, data, num_bytes);
-
+
// Note: this will be slow when DR to vram!
i=num_bytes;
while(2*i<=replen){
@@ -125,11 +125,11 @@ static void decode_rle_tga(TGAInfo *info, unsigned char *data, mp_image_t *mpi)
fast_memcpy(final, data, replen);
data += replen;
}
-
+
final += replen;
}
}
-
+
return;
}
@@ -138,7 +138,7 @@ static void decode_uncompressed_tga(TGAInfo *info, unsigned char *data, mp_image
{
unsigned char *final;
int row, num_bytes = info->bpp / 8;
-
+
/* see line 207 to see why this loop is set up like this */
for (row = info->start_row; (!info->origin && row) || (info->origin && row < info->height); row += info->increment)
{
@@ -154,7 +154,7 @@ static void decode_uncompressed_tga(TGAInfo *info, unsigned char *data, mp_image
static short read_tga_header(unsigned char *buf, TGAInfo *info)
{
info->id_len = buf[0];
-
+
info->img_type = buf[2];
/* targa data is always stored in little endian byte order */
@@ -162,11 +162,11 @@ static short read_tga_header(unsigned char *buf, TGAInfo *info)
info->height = le2me_16(*(unsigned short *) &buf[14]);
info->bpp = buf[16];
-
+
info->origin = (buf[17] & 0x20) >> 5;
/* FIXME check for valid targa data */
-
+
return 0;
}
@@ -177,13 +177,13 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
TGAInfo *info = sh->context;
unsigned char *data = raw;
mp_image_t *mpi;
-
-
+
+
if (len <= 0)
return NULL; /* skip frame */
read_tga_header(data, info); /* read information about the file */
-
+
if (info->bpp == 24)
out_fmt = IMGFMT_BGR24;
else if (info->bpp == 32)
@@ -193,7 +193,7 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported TGA type! depth=%d\n",info->bpp);
return NULL;
}
-
+
if (info->img_type != TGA_UNCOMP_TRUECOLOR && info->img_type != TGA_RLE_TRUECOLOR) /* not a true color image */
{
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported TGA type: %i!\n", info->img_type);
@@ -206,21 +206,21 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
/* set data to the beginning of the image data */
data += 18 + info->id_len;
-
+
/* (re)init libvo if image parameters changed (width/height/colorspace) */
if (last_w != info->width || last_h != info->height || last_c != out_fmt)
{
last_w = info->width;
last_h = info->height;
last_c = out_fmt;
-
+
if (!out_fmt || !mpcodecs_config_vo(sh, info->width, info->height, out_fmt))
return NULL;
}
if (!(mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, info->width, info->height)))
return NULL;
-
+
/* finally decode the image */
if (info->img_type == TGA_UNCOMP_TRUECOLOR)
decode_uncompressed_tga(info, data, mpi);
@@ -231,4 +231,3 @@ static mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
return mpi;
}
-