⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fame_shape.c

📁 一个很好用的MPEG1/4的开源编码器
💻 C
📖 第 1 页 / 共 2 页
字号:
  output = shape->recon + offset;  if(mb_y)  {    /* top border exists */    output -= pitch;     output -= pitch;    /* top left border (->output=(i=-2, j=0)) */    if(mb_x) {      /* copy from the previous reconstructed block */      output -= 2;         bab16x16[0][0] = bab8x8[0][0] = bab4x4[0][0] = output[0];      bab16x16[0][1] = bab8x8[0][1] = bab4x4[0][1] = output[1];      bab16x16[1][0] = bab8x8[1][0] = bab4x4[1][0] = output[pitch+0];      bab16x16[1][1] = bab8x8[1][1] = bab4x4[1][1] = output[pitch+1];      output += 2;    } else {      bab16x16[0][0] = bab8x8[0][0] = bab4x4[0][0] = 0;      bab16x16[0][1] = bab8x8[0][1] = bab4x4[0][1] = 0;      bab16x16[1][0] = bab8x8[1][0] = bab4x4[1][0] = 0;      bab16x16[1][1] = bab8x8[1][1] = bab4x4[1][1] = 0;    }    /* top border (->output=(i=-2, j=0)) */    for(j=2; j<18; j++) {      bab16x16[0][j] = output[0];      bab16x16[1][j] = output[pitch];      output++;    }    output -= 16;    for(j=2; j<10; j++) {      bab8x8[0][j] = output[0] | output[1];      bab8x8[1][j] = output[pitch+0] | output[pitch+1];      output+=2;    }    output -= 16;    for(j=2; j<6; j++) {      bab4x4[0][j] = ( (output[0] + output[1] + output[2] + output[3])>=2 )?1:0;      bab4x4[1][j] = ( (output[pitch+0] + output[pitch+1] + output[pitch+2] + output[pitch+3])>=2 )?1:0;      output+=4;    }    /* top right border (->output=(i=-2, j=16)) */    if(mb_x < shape->mb_width-1) {      /* copy from previous reconstructed block */      bab16x16[0][18] = bab8x8[0][10] = bab4x4[0][6] = output[0];      bab16x16[0][19] = bab8x8[0][11] = bab4x4[0][7] = output[1];      bab16x16[1][18] = bab8x8[1][10] = bab4x4[1][6] = output[pitch+0];      bab16x16[1][19] = bab8x8[1][11] = bab4x4[1][7] = output[pitch+1];    } else {      bab16x16[0][18] = bab8x8[0][10] = bab4x4[0][6] = 0;      bab16x16[0][19] = bab8x8[0][11] = bab4x4[0][7] = 0;      bab16x16[1][18] = bab8x8[1][10] = bab4x4[1][6] = 0;      bab16x16[1][19] = bab8x8[1][11] = bab4x4[1][7] = 0;    }  } else {    memset(bab16x16, 0, 2*20);    memset(bab8x8, 0, 2*12);    memset(bab4x4, 0, 2*8);  }  output = shape->recon + offset;  if(mb_x) {    /* left border exists */    output -= 2;    for(i=2; i<18; i++) {      bab16x16[i][0] = output[0];      bab16x16[i][1] = output[1];      output += pitch;    }    output -= (pitch<<4);    for(i=2; i<10; i++) {      bab8x8[i][0] = output[0] | output[pitch+0];      bab8x8[i][1] = output[1] | output[pitch+1];      output += (pitch<<1);    }    output -= (pitch<<4);    for(i=2; i<6; i++) {      bab4x4[i][0] = output[0] + output[pitch+0];      bab4x4[i][1] = output[1] + output[pitch+1];      output += (pitch<<1);      bab4x4[i][0] += output[0] + output[pitch+0];      bab4x4[i][1] += output[1] + output[pitch+1];      output += (pitch<<1);      bab4x4[i][0] = (bab4x4[i][0]>=2)?1:0;      bab4x4[i][1] = (bab4x4[i][1]>=2)?1:0;    }    output += 2;  } else {    for(i=2; i<18; i++) {      bab16x16[i][0] = 0;      bab16x16[i][1] = 0;    }    for(i=2; i<10; i++) {      bab8x8[i][0] = 0;      bab8x8[i][1] = 0;    }    for(i=2; i<6; i++) {      bab4x4[i][0] = 0;      bab4x4[i][1] = 0;    }  }  /* replicate padding for right & bottom borders */  for(j=2; j<18; j++)  {    bab16x16[j][19] = bab16x16[j][18] = bab16x16[j][17];    bab16x16[19][j] = bab16x16[18][j] = bab16x16[17][j];  }  bab16x16[18][0] = bab16x16[18][1] = bab16x16[18][2];  bab16x16[19][0] = bab16x16[19][1] = bab16x16[19][2];  bab16x16[18][19] = bab16x16[18][18] = bab16x16[18][17];  bab16x16[19][19] = bab16x16[19][18] = bab16x16[19][17];  for(j=2; j<10; j++)  {    bab8x8[11][j] = bab8x8[10][j] = bab8x8[9][j];    bab8x8[j][11] = bab8x8[j][10] = bab8x8[j][9];  }  bab8x8[10][0] = bab8x8[10][1] = bab8x8[10][2];  bab8x8[11][0] = bab8x8[11][1] = bab8x8[11][2];  bab8x8[10][11] = bab8x8[10][10] = bab8x8[10][9];  bab8x8[11][11] = bab8x8[11][10] = bab8x8[11][9];  for(j=2; j<6; j++)  {    bab4x4[7][j] = bab4x4[6][j] = bab4x4[5][j];    bab4x4[j][7] = bab4x4[j][6] = bab4x4[j][5];  }  bab4x4[6][0] = bab4x4[6][1] = bab4x4[6][2];  bab4x4[7][0] = bab4x4[7][1] = bab4x4[7][2];  bab4x4[6][7] = bab4x4[6][6] = bab4x4[6][5];  bab4x4[7][7] = bab4x4[7][6] = bab4x4[7][5];  /* --- Up-sampling (Interpolation) --- */  /* Interpolation of bab4x4 (upsampling) */  output = &tmp_recon4x4[1][1];  for(i=1; i<6; i++)  {    for(j=1; j<6; j++)    {      INTERPOLATION(bab4x4, i, j, interp, cf,		    output[0] = (interp>th[cf])?1:0,		    output[1] = (interp>th[cf])?1:0,		    output[1+SIZE_BAB8] = (interp>th[cf])?1:0,		    output[0+SIZE_BAB8] = (interp>th[cf])?1:0		    );      output += 2;    }    output += SIZE_BAB8*2 - 10;  }  /* Add the borders to the tmp_recon4x4 */  for(j=0; j<SIZE_BAB8; j++) {    tmp_recon4x4[0][j] = bab8x8[0][j];    tmp_recon4x4[1][j] = bab8x8[1][j];  }  for(i=2; i<SIZE_BAB8-2; i++) {    tmp_recon4x4[i][0] = bab8x8[i][0];    tmp_recon4x4[i][1] = bab8x8[i][1];  }  for(j=2; j<10; j++)  {    tmp_recon4x4[11][j] = tmp_recon4x4[10][j] = tmp_recon4x4[9][j];    tmp_recon4x4[j][11] = tmp_recon4x4[j][10] = tmp_recon4x4[j][9];  }  tmp_recon4x4[10][0] = tmp_recon4x4[10][1] = tmp_recon4x4[10][2];  tmp_recon4x4[11][0] = tmp_recon4x4[11][1] = tmp_recon4x4[11][2];  tmp_recon4x4[10][11] = tmp_recon4x4[10][10] = tmp_recon4x4[10][9];  tmp_recon4x4[11][11] = tmp_recon4x4[11][10] = tmp_recon4x4[11][9];  /* Interpolation to real size (16x16) */  output = &tmp_recon8x8[1][1];  for(i=1; i<10; i++)  {    for(j=1; j<10; j++)    {      INTERPOLATION(tmp_recon4x4, i, j, interp, cf,		    output[0] = (interp>th[cf])?1:0,		    output[1] = (interp>th[cf])?1:0,		    output[1+SIZE_BAB16] = (interp>th[cf])?1:0,		    output[0+SIZE_BAB16] = (interp>th[cf])?1:0		    );      output += 2;    }    output += SIZE_BAB16*2 - 18;  }  /* Has the bab4x4 accepted quality ? */   input = shape->input + offset;  is_bab_coded = 1;  for(i=0; i<16; i+=4)  {    for(j=0; j<16; j+=4)    {      error = mean_absolute_binary_error(input, pitch, &tmp_recon8x8[i+2][j+2], SIZE_BAB16, 4);      is_bab_coded &= (error>m_alpha_th)?0:1;      input += 4;    }    input += pitch4 - 16;  }  if(shape->flags & FAME_SHAPE_LOSSLESS)    is_bab_coded = 0;  if(is_bab_coded)  {    output = shape->recon + offset;    *pattern = 0;    for(i=0; i<16; i++) {      for(j=0; j<16; j++) {        output[j] = tmp_recon8x8[i+2][j+2];	*pattern |= (output[j] << (((i>>2)&2)+(j>>3)));      }      output += pitch;    }    /* correct replicate padding for CAE (bottom left corner padded from above) */    bab4x4[7][0] = bab4x4[6][0] = bab4x4[5][0];    bab4x4[7][1] = bab4x4[6][1] = bab4x4[5][1];    *bab = &bab4x4[0][0];    return bab_border_4x4;  }  /* Interpolation of bab8x8 (upsampling) */  output = &tmp_recon8x8[1][1];  for(i=1; i<10; i++)  {    for(j=1; j<10; j++)    {      INTERPOLATION(bab8x8, i, j, interp, cf,		    output[0] = (interp>th[cf])?1:0,		    output[1] = (interp>th[cf])?1:0,		    output[1+SIZE_BAB16] = (interp>th[cf])?1:0,		    output[0+SIZE_BAB16] = (interp>th[cf])?1:0		    );      output += 2;    }    output += SIZE_BAB16*2 - 18;  }  /* Has the bab8x8 accepted quality ? */   input = shape->input + offset;  is_bab_coded = 1;  for(i=0; i<16; i+=4)  {    for(j=0; j<16; j+=4)    {      error = mean_absolute_binary_error(input, pitch, &tmp_recon8x8[i+2][j+2], SIZE_BAB16, 4);      is_bab_coded &= (error>m_alpha_th)?0:1;      input += 4;    }    input += pitch4 - 16;  }  if(shape->flags & FAME_SHAPE_LOSSLESS)    is_bab_coded = 0;  if(is_bab_coded)  {    output = shape->recon + offset;    *pattern = 0;    for(i=0; i<16; i++) {      for(j=0; j<16; j++) {        output[j] = tmp_recon8x8[i+2][j+2];	*pattern |= (output[j] << (((i>>2)&2)+(j>>3)));      }      output += pitch;    }    /* correct replicate padding for CAE (bottom left corner padded from above) */    bab8x8[11][0] = bab8x8[10][0] = bab8x8[9][0];    bab8x8[11][1] = bab8x8[10][1] = bab8x8[9][1];        *bab = &bab8x8[0][0];    return bab_border_8x8;  }  /* No Interpolation */  input = shape->input + offset;  output = shape->recon + offset;  *pattern = 0;  for(i = 0; i < 16; i++) {    for(j = 0; j < 16; j++) {      output[j] = input[j] & 1;      *pattern |= (output[j] << (((i>>2)&2)+(j>>3)));    }    output += pitch;    input += pitch;  }  /* correct replicate padding for CAE (bottom left corner padded from above) */  bab16x16[19][0] = bab16x16[18][0] = bab16x16[17][0];  bab16x16[19][1] = bab16x16[18][1] = bab16x16[17][1];  *bab = &bab16x16[0][0];  return bab_border_16x16;   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -