static unsigned long iv_decode_frame(Indeo3DecodeContext *s, 
                                     unsigned char *buf, int buf_size) 
{
  unsigned int hdr_width, hdr_height,
    chroma_width, chroma_height;
  unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs;
  unsigned char *hdr_pos, *buf_pos;
  buf_pos = buf;
  buf_pos += 18;
  fflags1 = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  fflags3 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  fflags2 = *buf_pos++;
  buf_pos += 3;
  hdr_height = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  hdr_width = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
  chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
  offs1 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  offs2 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  offs3 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 8;
  hdr_pos = buf_pos;
  if(fflags3 == 0x80) return 4;
  if(fflags1 & 0x200) {
    s->cur_frame = s->iv_frame + 1;
    s->ref_frame = s->iv_frame;
  } else {
    s->cur_frame = s->iv_frame;
    s->ref_frame = s->iv_frame + 1;
  }
  buf_pos = buf + 16 + offs1;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, 
    hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(hdr_width, 160));
  if (!(s->avctx->flags & CODEC_FLAG_GRAY))
  {
  buf_pos = buf + 16 + offs2;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, 
    chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(chroma_width, 40));
  buf_pos = buf + 16 + offs3;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, 
    chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(chroma_width, 40));
  }
  return 8;
}
static unsigned long iv_decode_frame(Indeo3DecodeContext *s, 
                                     unsigned char *buf, int buf_size) 
{
  unsigned int hdr_width, hdr_height,
    chroma_width, chroma_height;
  unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs;
  unsigned char *hdr_pos, *buf_pos;
  buf_pos = buf;
  buf_pos += 18;
  fflags1 = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  fflags3 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  fflags2 = *buf_pos++;
  buf_pos += 3;
  hdr_height = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  hdr_width = le2me_16(*(uint16_t *)buf_pos);
  buf_pos += 2;
  chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc;
  chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc;
  offs1 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  offs2 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  offs3 = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 8;
  hdr_pos = buf_pos;
  if(fflags3 == 0x80) return 4;
  if(fflags1 & 0x200) {
    s->cur_frame = s->iv_frame + 1;
    s->ref_frame = s->iv_frame;
  } else {
    s->cur_frame = s->iv_frame;
    s->ref_frame = s->iv_frame + 1;
  }
  buf_pos = buf + 16 + offs1;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, 
    hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(hdr_width, 160));
  if (!(s->avctx->flags & CODEC_FLAG_GRAY))
  {
  buf_pos = buf + 16 + offs2;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, 
    chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(chroma_width, 40));
  buf_pos = buf + 16 + offs3;
  offs = le2me_32(*(uint32_t *)buf_pos);
  buf_pos += 4;
  iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, 
    chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, 
    min(chroma_width, 40));
  }
  return 8;
}
static unsigned long FUNC_0(Indeo3DecodeContext *VAR_0, 
                                     unsigned char *VAR_1, int VAR_2) 
{
  unsigned int VAR_3, VAR_4,
    VAR_5, VAR_6;
  unsigned long VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
  unsigned char *VAR_14, *VAR_15;
  VAR_15 = VAR_1;
  VAR_15 += 18;
  VAR_7 = le2me_16(*(uint16_t *)VAR_15);
  VAR_15 += 2;
  VAR_9 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  VAR_8 = *VAR_15++;
  VAR_15 += 3;
  VAR_4 = le2me_16(*(uint16_t *)VAR_15);
  VAR_15 += 2;
  VAR_3 = le2me_16(*(uint16_t *)VAR_15);
  VAR_15 += 2;
  VAR_6 = ((VAR_4 >> 2) + 3) & 0x7ffc;
  VAR_5 = ((VAR_3 >> 2) + 3) & 0x7ffc;
  VAR_10 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  VAR_11 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  VAR_12 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 8;
  VAR_14 = VAR_15;
  if(VAR_9 == 0x80) return 4;
  if(VAR_7 & 0x200) {
    VAR_0->cur_frame = VAR_0->iv_frame + 1;
    VAR_0->ref_frame = VAR_0->iv_frame;
  } else {
    VAR_0->cur_frame = VAR_0->iv_frame;
    VAR_0->ref_frame = VAR_0->iv_frame + 1;
  }
  VAR_15 = VAR_1 + 16 + VAR_10;
  VAR_13 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ybuf, VAR_0->ref_frame->Ybuf, VAR_3, 
    VAR_4, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15, 
    min(VAR_3, 160));
  if (!(VAR_0->avctx->flags & CODEC_FLAG_GRAY))
  {
  VAR_15 = VAR_1 + 16 + VAR_11;
  VAR_13 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Vbuf, VAR_0->ref_frame->Vbuf, VAR_5, 
    VAR_6, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15, 
    min(VAR_5, 40));
  VAR_15 = VAR_1 + 16 + VAR_12;
  VAR_13 = le2me_32(*(uint32_t *)VAR_15);
  VAR_15 += 4;
  iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ubuf, VAR_0->ref_frame->Ubuf, VAR_5, 
    VAR_6, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15, 
    min(VAR_5, 40));
  }
  return 8;
}
static unsigned long FUNC_0(Indeo3DecodeContext *VAR_0,
unsigned char *VAR_1, int VAR_2)
{ unsigned int VAR_3, VAR_4,
VAR_5, VAR_6; unsigned long VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13; unsigned char *VAR_14, *VAR_15; VAR_15 = VAR_1; VAR_15 += 18; VAR_7 = le2me_16(*(uint16_t *)VAR_15); VAR_15 += 2; VAR_9 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; VAR_8 = *VAR_15++; VAR_15 += 3; VAR_4 = le2me_16(*(uint16_t *)VAR_15); VAR_15 += 2; VAR_3 = le2me_16(*(uint16_t *)VAR_15); VAR_15 += 2; VAR_6 = ((VAR_4 >> 2) + 3) & 0x7ffc; VAR_5 = ((VAR_3 >> 2) + 3) & 0x7ffc; VAR_10 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; VAR_11 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; VAR_12 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 8; VAR_14 = VAR_15; if(VAR_9 == 0x80) return 4; if(VAR_7 & 0x200) { VAR_0->cur_frame = VAR_0->iv_frame + 1; VAR_0->ref_frame = VAR_0->iv_frame; } else { VAR_0->cur_frame = VAR_0->iv_frame; VAR_0->ref_frame = VAR_0->iv_frame + 1; } VAR_15 = VAR_1 + 16 + VAR_10; VAR_13 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ybuf, VAR_0->ref_frame->Ybuf, VAR_3,
VAR_4, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15,
min(VAR_3, 160)); if (!(VAR_0->avctx->flags & CODEC_FLAG_GRAY))
{ VAR_15 = VAR_1 + 16 + VAR_11; VAR_13 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Vbuf, VAR_0->ref_frame->Vbuf, VAR_5,
VAR_6, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15,
min(VAR_5, 40)); VAR_15 = VAR_1 + 16 + VAR_12; VAR_13 = le2me_32(*(uint32_t *)VAR_15); VAR_15 += 4; iv_Decode_Chunk(VAR_0, VAR_0->cur_frame->Ubuf, VAR_0->ref_frame->Ubuf, VAR_5,
VAR_6, VAR_15 + VAR_13 * 2, VAR_8, VAR_14, VAR_15,
min(VAR_5, 40)); } return 8; }