Revision 530902f3 libavcodec/4xm.c

View differences:

libavcodec/4xm.c
131 131
    AVFrame current_picture, last_picture;
132 132
    GetBitContext pre_gb;          ///< ac/dc prefix
133 133
    GetBitContext gb;
134
    uint8_t *bytestream;
135
    uint16_t *wordstream;
134
    const uint8_t *bytestream;
135
    const uint16_t *wordstream;
136 136
    int mv[256];
137 137
    VLC pre_vlc;
138 138
    int last_dc;
......
347 347
    return le2me_32(*(uint32_t*)p);
348 348
}
349 349

  
350
static int decode_p_frame(FourXContext *f, uint8_t *buf, int length){
350
static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){
351 351
    int x, y;
352 352
    const int width= f->avctx->width;
353 353
    const int height= f->avctx->height;
......
379 379
    }
380 380

  
381 381
    f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE);
382
    f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)(buf + extra), bitstream_size/4);
382
    f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)(buf + extra), bitstream_size/4);
383 383
    init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size);
384 384

  
385
    f->wordstream= (uint16_t*)(buf + extra + bitstream_size);
385
    f->wordstream= (const uint16_t*)(buf + extra + bitstream_size);
386 386
    f->bytestream= buf + extra + bitstream_size + wordstream_size;
387 387

  
388 388
    init_mv(f);
......
396 396
    }
397 397

  
398 398
    if(   bitstream_size != (get_bits_count(&f->gb)+31)/32*4
399
       || (((char*)f->wordstream - (char*)buf + 2)&~2) != extra + bitstream_size + wordstream_size
400
       || (((char*)f->bytestream - (char*)buf + 3)&~3) != extra + bitstream_size + wordstream_size + bytestream_size)
399
       || (((const char*)f->wordstream - (const char*)buf + 2)&~2) != extra + bitstream_size + wordstream_size
400
       || (((const char*)f->bytestream - (const char*)buf + 3)&~3) != extra + bitstream_size + wordstream_size + bytestream_size)
401 401
        av_log(f->avctx, AV_LOG_ERROR, " %d %td %td bytes left\n",
402 402
            bitstream_size - (get_bits_count(&f->gb)+31)/32*4,
403
            -(((char*)f->bytestream - (char*)buf + 3)&~3) + (extra + bitstream_size + wordstream_size + bytestream_size),
404
            -(((char*)f->wordstream - (char*)buf + 2)&~2) + (extra + bitstream_size + wordstream_size)
403
            -(((const char*)f->bytestream - (const char*)buf + 3)&~3) + (extra + bitstream_size + wordstream_size + bytestream_size),
404
            -(((const char*)f->wordstream - (const char*)buf + 2)&~2) + (extra + bitstream_size + wordstream_size)
405 405
        );
406 406

  
407 407
    return 0;
......
512 512
    return 0;
513 513
}
514 514

  
515
static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){
515
static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf){
516 516
    int frequency[512];
517 517
    uint8_t flag[512];
518 518
    int up[512];
519 519
    uint8_t len_tab[257];
520 520
    int bits_tab[257];
521 521
    int start, end;
522
    uint8_t *ptr= buf;
522
    const uint8_t *ptr= buf;
523 523
    int j;
524 524

  
525 525
    memset(frequency, 0, sizeof(frequency));
......
596 596
    return red/3*1024 + green/3*32 + blue/3;
597 597
}
598 598

  
599
static int decode_i2_frame(FourXContext *f, uint8_t *buf, int length){
599
static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length){
600 600
    int x, y, x2, y2;
601 601
    const int width= f->avctx->width;
602 602
    const int height= f->avctx->height;
......
632 632
    return 0;
633 633
}
634 634

  
635
static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){
635
static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){
636 636
    int x, y;
637 637
    const int width= f->avctx->width;
638 638
    const int height= f->avctx->height;
......
641 641
    const unsigned int bitstream_size= get32(buf);
642 642
    const int token_count av_unused = get32(buf + bitstream_size + 8);
643 643
    unsigned int prestream_size= 4*get32(buf + bitstream_size + 4);
644
    uint8_t *prestream= buf + bitstream_size + 12;
644
    const uint8_t *prestream= buf + bitstream_size + 12;
645 645

  
646 646
    if(prestream_size + bitstream_size + 12 != length
647 647
       || bitstream_size > (1<<26)
......
657 657
    prestream_size= length + buf - prestream;
658 658

  
659 659
    f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE);
660
    f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)prestream, prestream_size/4);
660
    f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4);
661 661
    init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size);
662 662

  
663 663
    f->last_dc= 0*128*8*8;
......
680 680

  
681 681
static int decode_frame(AVCodecContext *avctx,
682 682
                        void *data, int *data_size,
683
                        uint8_t *buf, int buf_size)
683
                        const uint8_t *buf, int buf_size)
684 684
{
685 685
    FourXContext * const f = avctx->priv_data;
686 686
    AVFrame *picture = data;

Also available in: Unified diff