Revision 2c4b4829

View differences:

libavcodec/indeo3.c
202 202

  
203 203
static void iv_Decode_Chunk(Indeo3DecodeContext *s,
204 204
        uint8_t *cur, uint8_t *ref, int width, int height,
205
        const uint8_t *buf1, long fflags2, const uint8_t *hdr,
205
        const uint8_t *buf1, long cb_offset, const uint8_t *hdr,
206 206
        const uint8_t *buf2, int min_width_160)
207 207
{
208 208
    uint8_t bit_buf;
......
314 314
            k = *buf1 >> 4;
315 315
            j = *buf1 & 0x0f;
316 316
            buf1++;
317
            lv = j + fflags2;
317
            lv = j + cb_offset;
318 318

  
319 319
            if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
320 320
                cp2 = s->ModPred + ((lv - 8) << 7);
......
326 326
            }
327 327

  
328 328
            if(k == 1 || k == 4) {
329
                lv = (hdr[j] & 0xf) + fflags2;
329
                lv = (hdr[j] & 0xf) + cb_offset;
330 330
                correction_type_sp[0] = s->corrector_type + (lv << 8);
331 331
                correction_lp[0] = correction + (lv << 8);
332
                lv = (hdr[j] >> 4) + fflags2;
332
                lv = (hdr[j] >> 4) + cb_offset;
333 333
                correction_lp[1] = correction + (lv << 8);
334 334
                correction_type_sp[1] = s->corrector_type + (lv << 8);
335 335
            } else {
......
973 973
static unsigned long iv_decode_frame(Indeo3DecodeContext *s,
974 974
                                     const uint8_t *buf, int buf_size)
975 975
{
976
    unsigned int hdr_width, hdr_height,
976
    unsigned int image_width, image_height,
977 977
                 chroma_width, chroma_height;
978
    unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs;
978
    unsigned long flags, cb_offset, data_size,
979
                  y_offset, v_offset, u_offset, mc_vector_count;
979 980
    const uint8_t *hdr_pos, *buf_pos;
980 981

  
981 982
    buf_pos = buf;
982
    buf_pos += 18;
983
    buf_pos += 18; /* skip OS header (16 bytes) and version number */
983 984

  
984
    fflags1 = bytestream_get_le16(&buf_pos);
985
    fflags3 = bytestream_get_le32(&buf_pos);
986
    fflags2 = *buf_pos++;
987
    buf_pos += 3;
988
    hdr_height = bytestream_get_le16(&buf_pos);
989
    hdr_width  = bytestream_get_le16(&buf_pos);
985
    flags = bytestream_get_le16(&buf_pos);
986
    data_size = bytestream_get_le32(&buf_pos);
987
    cb_offset = *buf_pos++;
988
    buf_pos += 3; /* skip reserved byte and checksum */
989
    image_height = bytestream_get_le16(&buf_pos);
990
    image_width  = bytestream_get_le16(&buf_pos);
990 991

  
991
    if(avcodec_check_dimensions(NULL, hdr_width, hdr_height))
992
    if(avcodec_check_dimensions(NULL, image_width, image_height))
992 993
        return -1;
993 994

  
994
    chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
995
    chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
996
    offs1 = bytestream_get_le32(&buf_pos);
997
    offs2 = bytestream_get_le32(&buf_pos);
998
    offs3 = bytestream_get_le32(&buf_pos);
999
    buf_pos += 4;
995
    chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
996
    chroma_width = ((image_width >> 2) + 3) & 0x7ffc;
997
    y_offset = bytestream_get_le32(&buf_pos);
998
    v_offset = bytestream_get_le32(&buf_pos);
999
    u_offset = bytestream_get_le32(&buf_pos);
1000
    buf_pos += 4; /* reserved */
1000 1001
    hdr_pos = buf_pos;
1001
    if(fflags3 == 0x80) return 4;
1002
    if(data_size == 0x80) return 4;
1002 1003

  
1003
    if(fflags1 & 0x200) {
1004
    if(flags & 0x200) {
1004 1005
        s->cur_frame = s->iv_frame + 1;
1005 1006
        s->ref_frame = s->iv_frame;
1006 1007
    } else {
......
1008 1009
        s->ref_frame = s->iv_frame + 1;
1009 1010
    }
1010 1011

  
1011
    buf_pos = buf + 16 + offs1;
1012
    offs = bytestream_get_le32(&buf_pos);
1012
    buf_pos = buf + 16 + y_offset;
1013
    mc_vector_count = bytestream_get_le32(&buf_pos);
1013 1014

  
1014
    iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width,
1015
                    hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
1016
                    FFMIN(hdr_width, 160));
1015
    iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width,
1016
                    image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1017
                    FFMIN(image_width, 160));
1017 1018

  
1018 1019
    if (!(s->avctx->flags & CODEC_FLAG_GRAY))
1019 1020
    {
1020 1021

  
1021
        buf_pos = buf + 16 + offs2;
1022
        offs = bytestream_get_le32(&buf_pos);
1022
        buf_pos = buf + 16 + v_offset;
1023
        mc_vector_count = bytestream_get_le32(&buf_pos);
1023 1024

  
1024 1025
        iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width,
1025
                chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
1026
                chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1026 1027
                FFMIN(chroma_width, 40));
1027 1028

  
1028
        buf_pos = buf + 16 + offs3;
1029
        offs = bytestream_get_le32(&buf_pos);
1029
        buf_pos = buf + 16 + u_offset;
1030
        mc_vector_count = bytestream_get_le32(&buf_pos);
1030 1031

  
1031 1032
        iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width,
1032
                chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos,
1033
                chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos,
1033 1034
                FFMIN(chroma_width, 40));
1034 1035

  
1035 1036
    }

Also available in: Unified diff