static void iv_Decode_Chunk(Indeo3DecodeContext *s,
  unsigned char *cur, unsigned char *ref, int width, int height,
  const unsigned char *buf1, long fflags2, const unsigned char *hdr,
  const unsigned char *buf2, int min_width_160)
{
  unsigned char bit_buf;
  unsigned long bit_pos, lv, lv1, lv2;
  long *width_tbl, width_tbl_arr[10];
  const signed char *ref_vectors;
  unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2;
  uint32_t *cur_lp, *ref_lp;
  const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2];
  unsigned short *correction_type_sp[2];
  ustr_t strip_tbl[20], *strip;
  int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,
    rle_v1, rle_v2, rle_v3;
  unsigned short res;
  bit_buf = 0;
  ref_vectors = NULL;
  width_tbl = width_tbl_arr + 1;
  i = (width < 0 ? width + 3 : width)/4;
  for(j = -1; j < 8; j++)
    width_tbl[j] = i * j;
  strip = strip_tbl;
  for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160);
  strip->ypos = strip->xpos = 0;
  for(strip->width = min_width_160; width > strip->width; strip->width *= 2);
  strip->height = height;
  strip->split_direction = 0;
  strip->split_flag = 0;
  strip->usl7 = 0;
  bit_pos = 0;
  rle_v1 = rle_v2 = rle_v3 = 0;
  while(strip >= strip_tbl) {
    if(bit_pos <= 0) {
      bit_pos = 8;
      bit_buf = *buf1++;
    }
    bit_pos -= 2;
    cmd = (bit_buf >> bit_pos) & 0x03;
    if(cmd == 0) {
      strip++;
      memcpy(strip, strip-1, sizeof(ustr_t));
      strip->split_flag = 1;
      strip->split_direction = 0;
      strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4);
      continue;
    } else if(cmd == 1) {
      strip++;
      memcpy(strip, strip-1, sizeof(ustr_t));
      strip->split_flag = 1;
      strip->split_direction = 1;
      strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4);
      continue;
    } else if(cmd == 2) {
      if(strip->usl7 == 0) {
        strip->usl7 = 1;
        ref_vectors = NULL;
        continue;
      }
    } else if(cmd == 3) {
      if(strip->usl7 == 0) {
        strip->usl7 = 1;
        ref_vectors = (const signed char*)buf2 + (*buf1 * 2);
        buf1++;
        continue;
      }
    }
    cur_frm_pos = cur + width * strip->ypos + strip->xpos;
    if((blks_width = strip->width) < 0)
      blks_width += 3;
    blks_width >>= 2;
    blks_height = strip->height;
    if(ref_vectors != NULL) {
      ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width +
        ref_vectors[1] + strip->xpos;
    } else
      ref_frm_pos = cur_frm_pos - width_tbl[4];
    if(cmd == 2) {
      if(bit_pos <= 0) {
        bit_pos = 8;
        bit_buf = *buf1++;
      }
      bit_pos -= 2;
      cmd = (bit_buf >> bit_pos) & 0x03;
      if(cmd == 0 || ref_vectors != NULL) {
        for(lp1 = 0; lp1 < blks_width; lp1++) {
          for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1])
            ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
          cur_frm_pos += 4;
          ref_frm_pos += 4;
        }
      } else if(cmd != 1)
        return;
    } else {
      k = *buf1 >> 4;
      j = *buf1 & 0x0f;
      buf1++;
      lv = j + fflags2;
      if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {
        cp2 = s->ModPred + ((lv - 8) << 7);
        cp = ref_frm_pos;
        for(i = 0; i < blks_width << 2; i++) {
            int v = *cp >> 1;
            *(cp++) = cp2[v];
        }
      }
      if(k == 1 || k == 4) {
        lv = (hdr[j] & 0xf) + fflags2;
        correction_type_sp[0] = s->corrector_type + (lv << 8);
        correction_lp[0] = correction + (lv << 8);
        lv = (hdr[j] >> 4) + fflags2;
        correction_lp[1] = correction + (lv << 8);
        correction_type_sp[1] = s->corrector_type + (lv << 8);
      } else {
        correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8);
        correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8);
        correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8);
        correction_lp[0] = correction_lp[1] = correction + (lv << 8);
      }
      switch(k) {
        case 1:
        case 0:
          for( ; blks_height > 0; blks_height -= 4) {
            for(lp1 = 0; lp1 < blks_width; lp1++) {
              for(lp2 = 0; lp2 < 4; ) {
                k = *buf1++;
                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2];
                ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2];
                switch(correction_type_sp[0][k]) {
                  case 0:
                    *cur_lp = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);
                    lp2++;
                    break;
                  case 1:
                    res = ((le2me_16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1;
                    ((unsigned short *)cur_lp)[0] = le2me_16(res);
                    res = ((le2me_16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
                    ((unsigned short *)cur_lp)[1] = le2me_16(res);
                    buf1++;
                    lp2++;
                    break;
                  case 2:
                    if(lp2 == 0) {
                      for(i = 0, j = 0; i < 2; i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                      lp2 += 2;
                    }
                    break;
                  case 3:
                    if(lp2 < 2) {
                      for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                      lp2 = 3;
                    }
                    break;
                  case 8:
                    if(lp2 == 0) {
                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
                      if(rle_v1 == 1 || ref_vectors != NULL) {
                        for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                          cur_lp[j] = ref_lp[j];
                      }
                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
                      break;
                    } else {
                      rle_v1 = 1;
                      rle_v2 = *buf1 - 1;
                    }
                  case 5:
                      LP2_CHECK(buf1,rle_v3,lp2)
                  case 4:
                    for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1])
                      cur_lp[j] = ref_lp[j];
                    lp2 = 4;
                    break;
                  case 7:
                    if(rle_v3 != 0)
                      rle_v3 = 0;
                    else {
                      buf1--;
                      rle_v3 = 1;
                    }
                  case 6:
                    if(ref_vectors != NULL) {
                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                    }
                    lp2 = 4;
                    break;
                  case 9:
                    lv1 = *buf1++;
                    lv = (lv1 & 0x7F) << 1;
                    lv += (lv << 8);
                    lv += (lv << 16);
                    for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                      cur_lp[j] = lv;
                    LV1_CHECK(buf1,rle_v3,lv1,lp2)
                    break;
                  default:
                    return;
                }
              }
              cur_frm_pos += 4;
              ref_frm_pos += 4;
            }
            cur_frm_pos += ((width - blks_width) * 4);
            ref_frm_pos += ((width - blks_width) * 4);
          }
          break;
        case 4:
        case 3:
          if(ref_vectors != NULL)
            return;
          flag1 = 1;
          for( ; blks_height > 0; blks_height -= 8) {
            for(lp1 = 0; lp1 < blks_width; lp1++) {
              for(lp2 = 0; lp2 < 4; ) {
                k = *buf1++;
                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
                ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
                switch(correction_type_sp[lp2 & 0x01][k]) {
                  case 0:
                    cur_lp[width_tbl[1]] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);
                    if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
                      cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                    else
                      cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);
                    lp2++;
                    break;
                  case 1:
                    res = ((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1;
                    ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res);
                    res = ((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1;
                    ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res);
                    if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)
                      cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                    else
                      cur_lp[0] = cur_lp[width_tbl[1]];
                    buf1++;
                    lp2++;
                    break;
                  case 2:
                    if(lp2 == 0) {
                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                        cur_lp[j] = *ref_lp;
                      lp2 += 2;
                    }
                    break;
                  case 3:
                    if(lp2 < 2) {
                      for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
                        cur_lp[j] = *ref_lp;
                      lp2 = 3;
                    }
                    break;
                  case 6:
                    lp2 = 4;
                    break;
                  case 7:
                    if(rle_v3 != 0)
                      rle_v3 = 0;
                    else {
                      buf1--;
                      rle_v3 = 1;
                    }
                    lp2 = 4;
                    break;
                  case 8:
                    if(lp2 == 0) {
                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
                      if(rle_v1 == 1) {
                        for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
                          cur_lp[j] = ref_lp[j];
                      }
                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
                      break;
                    } else {
                      rle_v2 = (*buf1) - 1;
                      rle_v1 = 1;
                    }
                  case 5:
                      LP2_CHECK(buf1,rle_v3,lp2)
                  case 4:
                    for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
                      cur_lp[j] = *ref_lp;
                    lp2 = 4;
                    break;
                  case 9:
                    av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                    lv1 = *buf1++;
                    lv = (lv1 & 0x7F) << 1;
                    lv += (lv << 8);
                    lv += (lv << 16);
                    for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                      cur_lp[j] = lv;
                    LV1_CHECK(buf1,rle_v3,lv1,lp2)
                    break;
                  default:
                    return;
                }
              }
              cur_frm_pos += 4;
            }
            cur_frm_pos += (((width * 2) - blks_width) * 4);
            flag1 = 0;
          }
          break;
        case 10:
          if(ref_vectors == NULL) {
            flag1 = 1;
            for( ; blks_height > 0; blks_height -= 8) {
              for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
                for(lp2 = 0; lp2 < 4; ) {
                  k = *buf1++;
                  cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
                  ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];
                  lv1 = ref_lp[0];
                  lv2 = ref_lp[1];
                  if(lp2 == 0 && flag1 != 0) {
#ifdef WORDS_BIGENDIAN
                    lv1 = lv1 & 0xFF00FF00;
                    lv1 = (lv1 >> 8) | lv1;
                    lv2 = lv2 & 0xFF00FF00;
                    lv2 = (lv2 >> 8) | lv2;
#else
                    lv1 = lv1 & 0x00FF00FF;
                    lv1 = (lv1 << 8) | lv1;
                    lv2 = lv2 & 0x00FF00FF;
                    lv2 = (lv2 << 8) | lv2;
#endif
                  }
                  switch(correction_type_sp[lp2 & 0x01][k]) {
                    case 0:
                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1);
                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1);
                      if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                      } else {
                        cur_lp[0] = cur_lp[width_tbl[1]];
                        cur_lp[1] = cur_lp[width_tbl[1]+1];
                      }
                      lp2++;
                      break;
                    case 1:
                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1);
                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1);
                      if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {
                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                      } else {
                        cur_lp[0] = cur_lp[width_tbl[1]];
                        cur_lp[1] = cur_lp[width_tbl[1]+1];
                      }
                      buf1++;
                      lp2++;
                      break;
                    case 2:
                      if(lp2 == 0) {
                        if(flag1 != 0) {
                          for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) {
                            cur_lp[j] = lv1;
                            cur_lp[j+1] = lv2;
                          }
                          cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                          cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                        } else {
                          for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
                            cur_lp[j] = lv1;
                            cur_lp[j+1] = lv2;
                          }
                        }
                        lp2 += 2;
                      }
                      break;
                    case 3:
                      if(lp2 < 2) {
                        if(lp2 == 0 && flag1 != 0) {
                          for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) {
                            cur_lp[j] = lv1;
                            cur_lp[j+1] = lv2;
                          }
                          cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                          cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                        } else {
                          for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
                            cur_lp[j] = lv1;
                            cur_lp[j+1] = lv2;
                          }
                        }
                        lp2 = 3;
                      }
                      break;
                    case 8:
                      if(lp2 == 0) {
                        RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
                        if(rle_v1 == 1) {
                          if(flag1 != 0) {
                            for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
                              cur_lp[j] = lv1;
                              cur_lp[j+1] = lv2;
                            }
                            cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                            cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                          } else {
                            for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
                              cur_lp[j] = lv1;
                              cur_lp[j+1] = lv2;
                            }
                          }
                        }
                        RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
                        break;
                      } else {
                        rle_v1 = 1;
                        rle_v2 = (*buf1) - 1;
                      }
                    case 5:
                        LP2_CHECK(buf1,rle_v3,lp2)
                    case 4:
                      if(lp2 == 0 && flag1 != 0) {
                        for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {
                          cur_lp[j] = lv1;
                          cur_lp[j+1] = lv2;
                        }
                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;
                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;
                      } else {
                        for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
                          cur_lp[j] = lv1;
                          cur_lp[j+1] = lv2;
                        }
                      }
                      lp2 = 4;
                      break;
                    case 6:
                      lp2 = 4;
                      break;
                    case 7:
                      if(lp2 == 0) {
                        if(rle_v3 != 0)
                          rle_v3 = 0;
                        else {
                          buf1--;
                          rle_v3 = 1;
                        }
                        lp2 = 4;
                      }
                      break;
                    case 9:
                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                      lv1 = *buf1;
                      lv = (lv1 & 0x7F) << 1;
                      lv += (lv << 8);
                      lv += (lv << 16);
                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
                        cur_lp[j] = lv;
                      LV1_CHECK(buf1,rle_v3,lv1,lp2)
                      break;
                    default:
                      return;
                  }
                }
                cur_frm_pos += 8;
              }
              cur_frm_pos += (((width * 2) - blks_width) * 4);
              flag1 = 0;
            }
          } else {
            for( ; blks_height > 0; blks_height -= 8) {
              for(lp1 = 0; lp1 < blks_width; lp1 += 2) {
                for(lp2 = 0; lp2 < 4; ) {
                  k = *buf1++;
                  cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
                  ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
                  switch(correction_type_sp[lp2 & 0x01][k]) {
                    case 0:
                      lv1 = correctionloworder_lp[lp2 & 0x01][k];
                      lv2 = correctionhighorder_lp[lp2 & 0x01][k];
                      cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1);
                      cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1);
                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1);
                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1);
                      lp2++;
                      break;
                    case 1:
                      lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++];
                      lv2 = correctionloworder_lp[lp2 & 0x01][k];
                      cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1);
                      cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1);
                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1);
                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1);
                      lp2++;
                      break;
                    case 2:
                      if(lp2 == 0) {
                        for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {
                          cur_lp[j] = ref_lp[j];
                          cur_lp[j+1] = ref_lp[j+1];
                        }
                        lp2 += 2;
                      }
                      break;
                    case 3:
                      if(lp2 < 2) {
                        for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {
                          cur_lp[j] = ref_lp[j];
                          cur_lp[j+1] = ref_lp[j+1];
                        }
                        lp2 = 3;
                      }
                      break;
                    case 8:
                      if(lp2 == 0) {
                        RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
                        for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {
                          ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];
                          ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1];
                        }
                        RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
                        break;
                      } else {
                        rle_v1 = 1;
                        rle_v2 = (*buf1) - 1;
                      }
                    case 5:
                    case 7:
                        LP2_CHECK(buf1,rle_v3,lp2)
                    case 6:
                    case 4:
                      for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {
                        cur_lp[j] = ref_lp[j];
                        cur_lp[j+1] = ref_lp[j+1];
                      }
                      lp2 = 4;
                      break;
                    case 9:
                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                      lv1 = *buf1;
                      lv = (lv1 & 0x7F) << 1;
                      lv += (lv << 8);
                      lv += (lv << 16);
                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
                        ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv;
                      LV1_CHECK(buf1,rle_v3,lv1,lp2)
                      break;
                    default:
                      return;
                  }
                }
                cur_frm_pos += 8;
                ref_frm_pos += 8;
              }
              cur_frm_pos += (((width * 2) - blks_width) * 4);
              ref_frm_pos += (((width * 2) - blks_width) * 4);
            }
          }
          break;
        case 11:
          if(ref_vectors == NULL)
            return;
          for( ; blks_height > 0; blks_height -= 8) {
            for(lp1 = 0; lp1 < blks_width; lp1++) {
              for(lp2 = 0; lp2 < 4; ) {
                k = *buf1++;
                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];
                ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];
                switch(correction_type_sp[lp2 & 0x01][k]) {
                  case 0:
                    cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);
                    cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);
                    lp2++;
                    break;
                  case 1:
                    lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]);
                    lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]);
                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1);
                    ((unsigned short *)cur_lp)[0] = le2me_16(res);
                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1);
                    ((unsigned short *)cur_lp)[1] = le2me_16(res);
                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1);
                    ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res);
                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1);
                    ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res);
                    lp2++;
                    break;
                  case 2:
                    if(lp2 == 0) {
                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                      lp2 += 2;
                    }
                    break;
                  case 3:
                    if(lp2 < 2) {
                      for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                      lp2 = 3;
                    }
                    break;
                  case 8:
                    if(lp2 == 0) {
                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)
                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])
                        cur_lp[j] = ref_lp[j];
                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)
                      break;
                    } else {
                      rle_v1 = 1;
                      rle_v2 = (*buf1) - 1;
                    }
                  case 5:
                  case 7:
                      LP2_CHECK(buf1,rle_v3,lp2)
                  case 4:
                  case 6:
                    for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])
                      cur_lp[j] = ref_lp[j];
                    lp2 = 4;
                    break;
                case 9:
                  av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n");
                  lv1 = *buf1++;
                  lv = (lv1 & 0x7F) << 1;
                  lv += (lv << 8);
                  lv += (lv << 16);
                  for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])
                    cur_lp[j] = lv;
                  LV1_CHECK(buf1,rle_v3,lv1,lp2)
                  break;
                  default:
                    return;
                }
              }
              cur_frm_pos += 4;
              ref_frm_pos += 4;
            }
            cur_frm_pos += (((width * 2) - blks_width) * 4);
            ref_frm_pos += (((width * 2) - blks_width) * 4);
          }
          break;
        default:
          return;
      }
    }
    if(strip < strip_tbl)
      return;
    for( ; strip >= strip_tbl; strip--) {
      if(strip->split_flag != 0) {
        strip->split_flag = 0;
        strip->usl7 = (strip-1)->usl7;
        if(strip->split_direction) {
          strip->xpos += strip->width;
          strip->width = (strip-1)->width - strip->width;
          if(region_160_width <= strip->xpos && width < strip->width + strip->xpos)
            strip->width = width - strip->xpos;
        } else {
          strip->ypos += strip->height;
          strip->height = (strip-1)->height - strip->height;
        }
        break;
      }
    }
  }
}
['static void iv_Decode_Chunk(Indeo3DecodeContext *s,\n  unsigned char *cur, unsigned char *ref, int width, int height,\n  const unsigned char *buf1, long fflags2, const unsigned char *hdr,\n  const unsigned char *buf2, int min_width_160)\n{\n  unsigned char bit_buf;\n  unsigned long bit_pos, lv, lv1, lv2;\n  long *width_tbl, width_tbl_arr[10];\n  const signed char *ref_vectors;\n  unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2;\n  uint32_t *cur_lp, *ref_lp;\n  const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2];\n  unsigned short *correction_type_sp[2];\n  ustr_t strip_tbl[20], *strip;\n  int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width,\n    rle_v1, rle_v2, rle_v3;\n  unsigned short res;\n  bit_buf = 0;\n  ref_vectors = NULL;\n  width_tbl = width_tbl_arr + 1;\n  i = (width < 0 ? width + 3 : width)/4;\n  for(j = -1; j < 8; j++)\n    width_tbl[j] = i * j;\n  strip = strip_tbl;\n  for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160);\n  strip->ypos = strip->xpos = 0;\n  for(strip->width = min_width_160; width > strip->width; strip->width *= 2);\n  strip->height = height;\n  strip->split_direction = 0;\n  strip->split_flag = 0;\n  strip->usl7 = 0;\n  bit_pos = 0;\n  rle_v1 = rle_v2 = rle_v3 = 0;\n  while(strip >= strip_tbl) {\n    if(bit_pos <= 0) {\n      bit_pos = 8;\n      bit_buf = *buf1++;\n    }\n    bit_pos -= 2;\n    cmd = (bit_buf >> bit_pos) & 0x03;\n    if(cmd == 0) {\n      strip++;\n      memcpy(strip, strip-1, sizeof(ustr_t));\n      strip->split_flag = 1;\n      strip->split_direction = 0;\n      strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4);\n      continue;\n    } else if(cmd == 1) {\n      strip++;\n      memcpy(strip, strip-1, sizeof(ustr_t));\n      strip->split_flag = 1;\n      strip->split_direction = 1;\n      strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4);\n      continue;\n    } else if(cmd == 2) {\n      if(strip->usl7 == 0) {\n        strip->usl7 = 1;\n        ref_vectors = NULL;\n        continue;\n      }\n    } else if(cmd == 3) {\n      if(strip->usl7 == 0) {\n        strip->usl7 = 1;\n        ref_vectors = (const signed char*)buf2 + (*buf1 * 2);\n        buf1++;\n        continue;\n      }\n    }\n    cur_frm_pos = cur + width * strip->ypos + strip->xpos;\n    if((blks_width = strip->width) < 0)\n      blks_width += 3;\n    blks_width >>= 2;\n    blks_height = strip->height;\n    if(ref_vectors != NULL) {\n      ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width +\n        ref_vectors[1] + strip->xpos;\n    } else\n      ref_frm_pos = cur_frm_pos - width_tbl[4];\n    if(cmd == 2) {\n      if(bit_pos <= 0) {\n        bit_pos = 8;\n        bit_buf = *buf1++;\n      }\n      bit_pos -= 2;\n      cmd = (bit_buf >> bit_pos) & 0x03;\n      if(cmd == 0 || ref_vectors != NULL) {\n        for(lp1 = 0; lp1 < blks_width; lp1++) {\n          for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1])\n            ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];\n          cur_frm_pos += 4;\n          ref_frm_pos += 4;\n        }\n      } else if(cmd != 1)\n        return;\n    } else {\n      k = *buf1 >> 4;\n      j = *buf1 & 0x0f;\n      buf1++;\n      lv = j + fflags2;\n      if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) {\n        cp2 = s->ModPred + ((lv - 8) << 7);\n        cp = ref_frm_pos;\n        for(i = 0; i < blks_width << 2; i++) {\n            int v = *cp >> 1;\n            *(cp++) = cp2[v];\n        }\n      }\n      if(k == 1 || k == 4) {\n        lv = (hdr[j] & 0xf) + fflags2;\n        correction_type_sp[0] = s->corrector_type + (lv << 8);\n        correction_lp[0] = correction + (lv << 8);\n        lv = (hdr[j] >> 4) + fflags2;\n        correction_lp[1] = correction + (lv << 8);\n        correction_type_sp[1] = s->corrector_type + (lv << 8);\n      } else {\n        correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8);\n        correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8);\n        correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8);\n        correction_lp[0] = correction_lp[1] = correction + (lv << 8);\n      }\n      switch(k) {\n        case 1:\n        case 0:\n          for( ; blks_height > 0; blks_height -= 4) {\n            for(lp1 = 0; lp1 < blks_width; lp1++) {\n              for(lp2 = 0; lp2 < 4; ) {\n                k = *buf1++;\n                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2];\n                ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2];\n                switch(correction_type_sp[0][k]) {\n                  case 0:\n                    *cur_lp = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);\n                    lp2++;\n                    break;\n                  case 1:\n                    res = ((le2me_16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1;\n                    ((unsigned short *)cur_lp)[0] = le2me_16(res);\n                    res = ((le2me_16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1;\n                    ((unsigned short *)cur_lp)[1] = le2me_16(res);\n                    buf1++;\n                    lp2++;\n                    break;\n                  case 2:\n                    if(lp2 == 0) {\n                      for(i = 0, j = 0; i < 2; i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                      lp2 += 2;\n                    }\n                    break;\n                  case 3:\n                    if(lp2 < 2) {\n                      for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                      lp2 = 3;\n                    }\n                    break;\n                  case 8:\n                    if(lp2 == 0) {\n                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)\n                      if(rle_v1 == 1 || ref_vectors != NULL) {\n                        for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                          cur_lp[j] = ref_lp[j];\n                      }\n                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)\n                      break;\n                    } else {\n                      rle_v1 = 1;\n                      rle_v2 = *buf1 - 1;\n                    }\n                  case 5:\n                      LP2_CHECK(buf1,rle_v3,lp2)\n                  case 4:\n                    for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1])\n                      cur_lp[j] = ref_lp[j];\n                    lp2 = 4;\n                    break;\n                  case 7:\n                    if(rle_v3 != 0)\n                      rle_v3 = 0;\n                    else {\n                      buf1--;\n                      rle_v3 = 1;\n                    }\n                  case 6:\n                    if(ref_vectors != NULL) {\n                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                    }\n                    lp2 = 4;\n                    break;\n                  case 9:\n                    lv1 = *buf1++;\n                    lv = (lv1 & 0x7F) << 1;\n                    lv += (lv << 8);\n                    lv += (lv << 16);\n                    for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                      cur_lp[j] = lv;\n                    LV1_CHECK(buf1,rle_v3,lv1,lp2)\n                    break;\n                  default:\n                    return;\n                }\n              }\n              cur_frm_pos += 4;\n              ref_frm_pos += 4;\n            }\n            cur_frm_pos += ((width - blks_width) * 4);\n            ref_frm_pos += ((width - blks_width) * 4);\n          }\n          break;\n        case 4:\n        case 3:\n          if(ref_vectors != NULL)\n            return;\n          flag1 = 1;\n          for( ; blks_height > 0; blks_height -= 8) {\n            for(lp1 = 0; lp1 < blks_width; lp1++) {\n              for(lp2 = 0; lp2 < 4; ) {\n                k = *buf1++;\n                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];\n                ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];\n                switch(correction_type_sp[lp2 & 0x01][k]) {\n                  case 0:\n                    cur_lp[width_tbl[1]] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);\n                    if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)\n                      cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                    else\n                      cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);\n                    lp2++;\n                    break;\n                  case 1:\n                    res = ((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1;\n                    ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res);\n                    res = ((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1;\n                    ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res);\n                    if(lp2 > 0 || flag1 == 0 || strip->ypos != 0)\n                      cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                    else\n                      cur_lp[0] = cur_lp[width_tbl[1]];\n                    buf1++;\n                    lp2++;\n                    break;\n                  case 2:\n                    if(lp2 == 0) {\n                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                        cur_lp[j] = *ref_lp;\n                      lp2 += 2;\n                    }\n                    break;\n                  case 3:\n                    if(lp2 < 2) {\n                      for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])\n                        cur_lp[j] = *ref_lp;\n                      lp2 = 3;\n                    }\n                    break;\n                  case 6:\n                    lp2 = 4;\n                    break;\n                  case 7:\n                    if(rle_v3 != 0)\n                      rle_v3 = 0;\n                    else {\n                      buf1--;\n                      rle_v3 = 1;\n                    }\n                    lp2 = 4;\n                    break;\n                  case 8:\n                    if(lp2 == 0) {\n                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)\n                      if(rle_v1 == 1) {\n                        for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])\n                          cur_lp[j] = ref_lp[j];\n                      }\n                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)\n                      break;\n                    } else {\n                      rle_v2 = (*buf1) - 1;\n                      rle_v1 = 1;\n                    }\n                  case 5:\n                      LP2_CHECK(buf1,rle_v3,lp2)\n                  case 4:\n                    for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])\n                      cur_lp[j] = *ref_lp;\n                    lp2 = 4;\n                    break;\n                  case 9:\n                    av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\\n");\n                    lv1 = *buf1++;\n                    lv = (lv1 & 0x7F) << 1;\n                    lv += (lv << 8);\n                    lv += (lv << 16);\n                    for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                      cur_lp[j] = lv;\n                    LV1_CHECK(buf1,rle_v3,lv1,lp2)\n                    break;\n                  default:\n                    return;\n                }\n              }\n              cur_frm_pos += 4;\n            }\n            cur_frm_pos += (((width * 2) - blks_width) * 4);\n            flag1 = 0;\n          }\n          break;\n        case 10:\n          if(ref_vectors == NULL) {\n            flag1 = 1;\n            for( ; blks_height > 0; blks_height -= 8) {\n              for(lp1 = 0; lp1 < blks_width; lp1 += 2) {\n                for(lp2 = 0; lp2 < 4; ) {\n                  k = *buf1++;\n                  cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];\n                  ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1];\n                  lv1 = ref_lp[0];\n                  lv2 = ref_lp[1];\n                  if(lp2 == 0 && flag1 != 0) {\n#ifdef WORDS_BIGENDIAN\n                    lv1 = lv1 & 0xFF00FF00;\n                    lv1 = (lv1 >> 8) | lv1;\n                    lv2 = lv2 & 0xFF00FF00;\n                    lv2 = (lv2 >> 8) | lv2;\n#else\n                    lv1 = lv1 & 0x00FF00FF;\n                    lv1 = (lv1 << 8) | lv1;\n                    lv2 = lv2 & 0x00FF00FF;\n                    lv2 = (lv2 << 8) | lv2;\n#endif\n                  }\n                  switch(correction_type_sp[lp2 & 0x01][k]) {\n                    case 0:\n                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1);\n                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1);\n                      if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {\n                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                      } else {\n                        cur_lp[0] = cur_lp[width_tbl[1]];\n                        cur_lp[1] = cur_lp[width_tbl[1]+1];\n                      }\n                      lp2++;\n                      break;\n                    case 1:\n                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1);\n                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1);\n                      if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) {\n                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                      } else {\n                        cur_lp[0] = cur_lp[width_tbl[1]];\n                        cur_lp[1] = cur_lp[width_tbl[1]+1];\n                      }\n                      buf1++;\n                      lp2++;\n                      break;\n                    case 2:\n                      if(lp2 == 0) {\n                        if(flag1 != 0) {\n                          for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) {\n                            cur_lp[j] = lv1;\n                            cur_lp[j+1] = lv2;\n                          }\n                          cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                          cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                        } else {\n                          for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {\n                            cur_lp[j] = lv1;\n                            cur_lp[j+1] = lv2;\n                          }\n                        }\n                        lp2 += 2;\n                      }\n                      break;\n                    case 3:\n                      if(lp2 < 2) {\n                        if(lp2 == 0 && flag1 != 0) {\n                          for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) {\n                            cur_lp[j] = lv1;\n                            cur_lp[j+1] = lv2;\n                          }\n                          cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                          cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                        } else {\n                          for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {\n                            cur_lp[j] = lv1;\n                            cur_lp[j+1] = lv2;\n                          }\n                        }\n                        lp2 = 3;\n                      }\n                      break;\n                    case 8:\n                      if(lp2 == 0) {\n                        RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)\n                        if(rle_v1 == 1) {\n                          if(flag1 != 0) {\n                            for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {\n                              cur_lp[j] = lv1;\n                              cur_lp[j+1] = lv2;\n                            }\n                            cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                            cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                          } else {\n                            for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {\n                              cur_lp[j] = lv1;\n                              cur_lp[j+1] = lv2;\n                            }\n                          }\n                        }\n                        RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)\n                        break;\n                      } else {\n                        rle_v1 = 1;\n                        rle_v2 = (*buf1) - 1;\n                      }\n                    case 5:\n                        LP2_CHECK(buf1,rle_v3,lp2)\n                    case 4:\n                      if(lp2 == 0 && flag1 != 0) {\n                        for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) {\n                          cur_lp[j] = lv1;\n                          cur_lp[j+1] = lv2;\n                        }\n                        cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE;\n                        cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE;\n                      } else {\n                        for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {\n                          cur_lp[j] = lv1;\n                          cur_lp[j+1] = lv2;\n                        }\n                      }\n                      lp2 = 4;\n                      break;\n                    case 6:\n                      lp2 = 4;\n                      break;\n                    case 7:\n                      if(lp2 == 0) {\n                        if(rle_v3 != 0)\n                          rle_v3 = 0;\n                        else {\n                          buf1--;\n                          rle_v3 = 1;\n                        }\n                        lp2 = 4;\n                      }\n                      break;\n                    case 9:\n                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\\n");\n                      lv1 = *buf1;\n                      lv = (lv1 & 0x7F) << 1;\n                      lv += (lv << 8);\n                      lv += (lv << 16);\n                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])\n                        cur_lp[j] = lv;\n                      LV1_CHECK(buf1,rle_v3,lv1,lp2)\n                      break;\n                    default:\n                      return;\n                  }\n                }\n                cur_frm_pos += 8;\n              }\n              cur_frm_pos += (((width * 2) - blks_width) * 4);\n              flag1 = 0;\n            }\n          } else {\n            for( ; blks_height > 0; blks_height -= 8) {\n              for(lp1 = 0; lp1 < blks_width; lp1 += 2) {\n                for(lp2 = 0; lp2 < 4; ) {\n                  k = *buf1++;\n                  cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];\n                  ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];\n                  switch(correction_type_sp[lp2 & 0x01][k]) {\n                    case 0:\n                      lv1 = correctionloworder_lp[lp2 & 0x01][k];\n                      lv2 = correctionhighorder_lp[lp2 & 0x01][k];\n                      cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1);\n                      cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1);\n                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1);\n                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1);\n                      lp2++;\n                      break;\n                    case 1:\n                      lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++];\n                      lv2 = correctionloworder_lp[lp2 & 0x01][k];\n                      cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1);\n                      cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1);\n                      cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1);\n                      cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1);\n                      lp2++;\n                      break;\n                    case 2:\n                      if(lp2 == 0) {\n                        for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) {\n                          cur_lp[j] = ref_lp[j];\n                          cur_lp[j+1] = ref_lp[j+1];\n                        }\n                        lp2 += 2;\n                      }\n                      break;\n                    case 3:\n                      if(lp2 < 2) {\n                        for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) {\n                          cur_lp[j] = ref_lp[j];\n                          cur_lp[j+1] = ref_lp[j+1];\n                        }\n                        lp2 = 3;\n                      }\n                      break;\n                    case 8:\n                      if(lp2 == 0) {\n                        RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)\n                        for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) {\n                          ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j];\n                          ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1];\n                        }\n                        RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)\n                        break;\n                      } else {\n                        rle_v1 = 1;\n                        rle_v2 = (*buf1) - 1;\n                      }\n                    case 5:\n                    case 7:\n                        LP2_CHECK(buf1,rle_v3,lp2)\n                    case 6:\n                    case 4:\n                      for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) {\n                        cur_lp[j] = ref_lp[j];\n                        cur_lp[j+1] = ref_lp[j+1];\n                      }\n                      lp2 = 4;\n                      break;\n                    case 9:\n                      av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\\n");\n                      lv1 = *buf1;\n                      lv = (lv1 & 0x7F) << 1;\n                      lv += (lv << 8);\n                      lv += (lv << 16);\n                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])\n                        ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv;\n                      LV1_CHECK(buf1,rle_v3,lv1,lp2)\n                      break;\n                    default:\n                      return;\n                  }\n                }\n                cur_frm_pos += 8;\n                ref_frm_pos += 8;\n              }\n              cur_frm_pos += (((width * 2) - blks_width) * 4);\n              ref_frm_pos += (((width * 2) - blks_width) * 4);\n            }\n          }\n          break;\n        case 11:\n          if(ref_vectors == NULL)\n            return;\n          for( ; blks_height > 0; blks_height -= 8) {\n            for(lp1 = 0; lp1 < blks_width; lp1++) {\n              for(lp2 = 0; lp2 < 4; ) {\n                k = *buf1++;\n                cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2];\n                ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2];\n                switch(correction_type_sp[lp2 & 0x01][k]) {\n                  case 0:\n                    cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);\n                    cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1);\n                    lp2++;\n                    break;\n                  case 1:\n                    lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]);\n                    lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]);\n                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1);\n                    ((unsigned short *)cur_lp)[0] = le2me_16(res);\n                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1);\n                    ((unsigned short *)cur_lp)[1] = le2me_16(res);\n                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1);\n                    ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res);\n                    res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1);\n                    ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res);\n                    lp2++;\n                    break;\n                  case 2:\n                    if(lp2 == 0) {\n                      for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                      lp2 += 2;\n                    }\n                    break;\n                  case 3:\n                    if(lp2 < 2) {\n                      for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                      lp2 = 3;\n                    }\n                    break;\n                  case 8:\n                    if(lp2 == 0) {\n                      RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3)\n                      for(i = 0, j = 0; i < 8; i++, j += width_tbl[1])\n                        cur_lp[j] = ref_lp[j];\n                      RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2)\n                      break;\n                    } else {\n                      rle_v1 = 1;\n                      rle_v2 = (*buf1) - 1;\n                    }\n                  case 5:\n                  case 7:\n                      LP2_CHECK(buf1,rle_v3,lp2)\n                  case 4:\n                  case 6:\n                    for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1])\n                      cur_lp[j] = ref_lp[j];\n                    lp2 = 4;\n                    break;\n                case 9:\n                  av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\\n");\n                  lv1 = *buf1++;\n                  lv = (lv1 & 0x7F) << 1;\n                  lv += (lv << 8);\n                  lv += (lv << 16);\n                  for(i = 0, j = 0; i < 4; i++, j += width_tbl[1])\n                    cur_lp[j] = lv;\n                  LV1_CHECK(buf1,rle_v3,lv1,lp2)\n                  break;\n                  default:\n                    return;\n                }\n              }\n              cur_frm_pos += 4;\n              ref_frm_pos += 4;\n            }\n            cur_frm_pos += (((width * 2) - blks_width) * 4);\n            ref_frm_pos += (((width * 2) - blks_width) * 4);\n          }\n          break;\n        default:\n          return;\n      }\n    }\n    if(strip < strip_tbl)\n      return;\n    for( ; strip >= strip_tbl; strip--) {\n      if(strip->split_flag != 0) {\n        strip->split_flag = 0;\n        strip->usl7 = (strip-1)->usl7;\n        if(strip->split_direction) {\n          strip->xpos += strip->width;\n          strip->width = (strip-1)->width - strip->width;\n          if(region_160_width <= strip->xpos && width < strip->width + strip->xpos)\n            strip->width = width - strip->xpos;\n        } else {\n          strip->ypos += strip->height;\n          strip->height = (strip-1)->height - strip->height;\n        }\n        break;\n      }\n    }\n  }\n}']