comparison smacker.c @ 6316:80f5ff30ba58 libavcodec

Use bytestream_get_be24 to simplify palette parsing.
author reimar
date Sat, 02 Feb 2008 22:31:11 +0000
parents 743c1ef20291
children 2f44646383c8
comparison
equal deleted inserted replaced
6315:9ac5c0cfeb56 6316:80f5ff30ba58
33 33
34 #include "avcodec.h" 34 #include "avcodec.h"
35 35
36 #define ALT_BITSTREAM_READER_LE 36 #define ALT_BITSTREAM_READER_LE
37 #include "bitstream.h" 37 #include "bitstream.h"
38 #include "bytestream.h"
38 39
39 #define SMKTREE_BITS 9 40 #define SMKTREE_BITS 9
40 #define SMK_NODE 0x80000000 41 #define SMK_NODE 0x80000000
41 42
42 /* 43 /*
365 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); 366 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
366 return -1; 367 return -1;
367 } 368 }
368 369
369 /* make the palette available on the way out */ 370 /* make the palette available on the way out */
370 out = buf + 1;
371 pal = (uint32_t*)smk->pic.data[1]; 371 pal = (uint32_t*)smk->pic.data[1];
372 smk->pic.palette_has_changed = buf[0] & 1; 372 smk->pic.palette_has_changed = buf[0] & 1;
373 smk->pic.key_frame = !!(buf[0] & 2); 373 smk->pic.key_frame = !!(buf[0] & 2);
374 if(smk->pic.key_frame) 374 if(smk->pic.key_frame)
375 smk->pic.pict_type = FF_I_TYPE; 375 smk->pic.pict_type = FF_I_TYPE;
376 else 376 else
377 smk->pic.pict_type = FF_P_TYPE; 377 smk->pic.pict_type = FF_P_TYPE;
378 378
379 for(i = 0; i < 256; i++) { 379 buf++;
380 int r, g, b; 380 for(i = 0; i < 256; i++)
381 r = *out++; 381 *pal++ = bytestream_get_be24(&buf);
382 g = *out++; 382 buf_size -= 769;
383 b = *out++;
384 *pal++ = (r << 16) | (g << 8) | b;
385 }
386 383
387 last_reset(smk->mmap_tbl, smk->mmap_last); 384 last_reset(smk->mmap_tbl, smk->mmap_last);
388 last_reset(smk->mclr_tbl, smk->mclr_last); 385 last_reset(smk->mclr_tbl, smk->mclr_last);
389 last_reset(smk->full_tbl, smk->full_last); 386 last_reset(smk->full_tbl, smk->full_last);
390 last_reset(smk->type_tbl, smk->type_last); 387 last_reset(smk->type_tbl, smk->type_last);
391 init_get_bits(&gb, buf + 769, (buf_size - 769) * 8); 388 init_get_bits(&gb, buf, buf_size * 8);
392 389
393 blk = 0; 390 blk = 0;
394 bw = avctx->width >> 2; 391 bw = avctx->width >> 2;
395 bh = avctx->height >> 2; 392 bh = avctx->height >> 2;
396 blocks = bw * bh; 393 blocks = bw * bh;