targa: Simplify using bytestream_get functions.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
This commit is contained in:
Reimar Döffinger 2011-06-27 19:05:49 +02:00
parent 5129336714
commit efdb198e00
1 changed files with 8 additions and 10 deletions

View File

@ -22,6 +22,7 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h" #include "libavutil/imgutils.h"
#include "avcodec.h" #include "avcodec.h"
#include "bytestream.h"
#include "targa.h" #include "targa.h"
typedef struct TargaContext { typedef struct TargaContext {
@ -116,13 +117,13 @@ static int decode_frame(AVCodecContext *avctx,
idlen = *buf++; idlen = *buf++;
buf++; /* pal */ buf++; /* pal */
compr = *buf++; compr = *buf++;
first_clr = AV_RL16(buf); buf += 2; first_clr = bytestream_get_le16(&buf);
colors = AV_RL16(buf); buf += 2; colors = bytestream_get_le16(&buf);
csize = *buf++; csize = *buf++;
buf += 2; /* x */ buf += 2; /* x */
y = AV_RL16(buf); buf += 2; y = bytestream_get_le16(&buf);
w = AV_RL16(buf); buf += 2; w = bytestream_get_le16(&buf);
h = AV_RL16(buf); buf += 2; h = bytestream_get_le16(&buf);
bpp = *buf++; bpp = *buf++;
flags = *buf++; flags = *buf++;
//skip identifier if any //skip identifier if any
@ -186,13 +187,10 @@ static int decode_frame(AVCodecContext *avctx,
if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway
buf += pal_size; buf += pal_size;
else{ else{
int r, g, b, t; int t;
int32_t *pal = ((int32_t*)p->data[1]) + first_clr; int32_t *pal = ((int32_t*)p->data[1]) + first_clr;
for(t = 0; t < colors; t++){ for(t = 0; t < colors; t++){
b = *buf++; *pal++ = (0xff<<24) | bytestream_get_le24(&buf);
g = *buf++;
r = *buf++;
*pal++ = (0xff<<24) | (r << 16) | (g << 8) | b;
} }
p->palette_has_changed = 1; p->palette_has_changed = 1;
} }