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

📄 img_luma.c

📁 压缩JM12.3d的完整的全部C语言的代码文档,用于嵌入式系统的压缩编解码
💻 C
📖 第 1 页 / 共 2 页
字号:
      jhigh2 = jpad + 2;
      jhigh3 = jpad + 3;
      for (ipad = 0; ipad < xpadded_size; ipad++)
      {
        is =
          (tap0 * (wxBufSrc[jpad ][ipad] + wxBufSrc[jhigh1][ipad]) +
          tap1 *  (wxBufSrc[jlow1][ipad] + wxBufSrc[jhigh2][ipad]) +
          tap2 *  (wxBufSrc[jlow2][ipad] + wxBufSrc[jhigh3][ipad]));

        wxLineDst[ipad] = (imgpel) iClip3 (0, img->max_imgpel_value, rshift_rnd_sf( is, 5 ) );
      }
    }

    // bottom
    for (jpad = ypadded_size - 3; jpad < ypadded_size; jpad++)
    {
      wxLineDst = wxBufDst[jpad];
      jlow1  = jpad - 1;
      jlow2  = jpad - 2;
      jhigh1 = imin (maxy, jpad + 1);
      jhigh2 = imin (maxy, jpad + 2);
      jhigh3 = imin (maxy, jpad + 3);
      for (ipad = 0; ipad < xpadded_size; ipad++)
      {
        is =
          (tap0 * (wxBufSrc[jpad ][ipad] + wxBufSrc[jhigh1][ipad]) +
          tap1 *  (wxBufSrc[jlow1][ipad] + wxBufSrc[jhigh2][ipad]) +
          tap2 *  (wxBufSrc[jlow2][ipad] + wxBufSrc[jhigh3][ipad]));

        wxLineDst[ipad] = (imgpel) iClip3 (0, img->max_imgpel_value, rshift_rnd_sf( is, 5 ) );
      }
    }
  }
  else
  {
    // top
    for (jpad = 0; jpad < 2; jpad++)
    {
      wxLineDst = wxBufDst[jpad];
      jlow1  = imax (0, jpad - 1);
      jlow2  = imax (0, jpad - 2);
      jhigh1 = jpad + 1;
      jhigh2 = jpad + 2;
      jhigh3 = jpad + 3;

      for (ipad = 0; ipad < xpadded_size; ipad++)
      {
        is =
          (tap0 * (imgY_sub_tmp[jpad ][ipad] + imgY_sub_tmp[jhigh1][ipad]) +
          tap1 *  (imgY_sub_tmp[jlow1][ipad] + imgY_sub_tmp[jhigh2][ipad]) +
          tap2 *  (imgY_sub_tmp[jlow2][ipad] + imgY_sub_tmp[jhigh3][ipad]));

        wxLineDst[ipad] = (imgpel) iClip3 (0, img->max_imgpel_value, rshift_rnd_sf( is, 10 ) );
      }
    }

    // center
    for (jpad = 2; jpad < ypadded_size - 3; jpad++)
    {
      wxLineDst = wxBufDst[jpad];
      jlow1  = jpad - 1;
      jlow2  = jpad - 2;
      jhigh1 = jpad + 1;
      jhigh2 = jpad + 2;
      jhigh3 = jpad + 3;
      for (ipad = 0; ipad < xpadded_size; ipad++)
      {
        is =
          (tap0 * (imgY_sub_tmp[jpad ][ipad] + imgY_sub_tmp[jhigh1][ipad]) +
          tap1 *  (imgY_sub_tmp[jlow1][ipad] + imgY_sub_tmp[jhigh2][ipad]) +
          tap2 *  (imgY_sub_tmp[jlow2][ipad] + imgY_sub_tmp[jhigh3][ipad]));

        wxLineDst[ipad] = (imgpel) iClip3 (0, img->max_imgpel_value, rshift_rnd_sf( is, 10 ) );
      }
    }

    // bottom
    for (jpad = ypadded_size - 3; jpad < ypadded_size; jpad++)
    {
      wxLineDst = wxBufDst[jpad];
      jlow1  = jpad - 1;
      jlow2  = jpad - 2;
      jhigh1 = imin (maxy, jpad + 1);
      jhigh2 = imin (maxy, jpad + 2);
      jhigh3 = imin (maxy, jpad + 3);
      for (ipad = 0; ipad < xpadded_size; ipad++)
      {
        is =
          (tap0 * (imgY_sub_tmp[jpad ][ipad] + imgY_sub_tmp[jhigh1][ipad]) +
          tap1 *  (imgY_sub_tmp[jlow1][ipad] + imgY_sub_tmp[jhigh2][ipad]) +
          tap2 *  (imgY_sub_tmp[jlow2][ipad] + imgY_sub_tmp[jhigh3][ipad]));

        wxLineDst[ipad] = (imgpel) iClip3 (0, img->max_imgpel_value, rshift_rnd_sf( is, 10 ) );
      }
    }

  }
}


/*!
 ************************************************************************
 * \brief
 *    Does _horizontal_ interpolation using the BiLinear filter
 *
 * \param s
 *    pointer to StorablePicture structure
 * \param dst_y
 *    vertical index to sub-image being generated
 * \param dst_x
 *    horizontal index to sub-image being generated
 * \param src_y_l
 *    vertical index to "LEFT" source sub-image
 * \param src_x_l
 *    horizontal index to "LEFT" source sub-image
 * \param src_y_r
 *    vertical index to "RIGHT" source sub-image
 * \param src_x_r
 *    horizontal index to "RIGHT" source sub-image
 * \param offset
 *    offset (either +0 or +1) for RIGHT sub-image HOR coordinate
 ************************************************************************
 */
void getHorSubImageBiLinear( StorablePicture *s, int dst_y, int dst_x, int src_y_l, int src_x_l, int src_y_r, int src_x_r, int offset )
{
  int jpad;
  int ipad;
  int ypadded_size = s->size_y + 2 * IMG_PAD_SIZE;
  int xpadded_size = s->size_x + 2 * IMG_PAD_SIZE;
  int maxx = xpadded_size - 1;

  imgpel *wBufSrcL, *wBufSrcR, *wBufDst;
  int xpadded_size_left = maxx - offset;

  for (jpad = 0; jpad < ypadded_size; jpad++)
  {
    wBufSrcL = s->curr_imgY_sub[src_y_l][src_x_l][jpad]; // 4:4:4 independent mode
    wBufSrcR = s->curr_imgY_sub[src_y_r][src_x_r][jpad]; // 4:4:4 independent mode
    wBufDst = s->curr_imgY_sub[dst_y][dst_x][jpad];      // 4:4:4 independent mode

    // left padded area + center
    for (ipad = 0; ipad < xpadded_size_left; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf( wBufSrcL[ipad] + wBufSrcR[ipad + offset], 1 );
    }
    // right padded area
    for (ipad = xpadded_size_left; ipad < xpadded_size; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf( wBufSrcL[ipad] + wBufSrcR[maxx], 1 );
    }
  }
}


/*!
 ************************************************************************
 * \brief
 *    Does _vertical_ interpolation using the BiLinear filter
 *
 * \param s
 *    pointer to StorablePicture structure
 * \param dst_x
 *    horizontal index to sub-image being generated
 * \param dst_y
 *    vertical index to sub-image being generated
 * \param src_x_l
 *    horizontal index to "TOP" source sub-image
 * \param src_y_l
 *    vertical index to "TOP" source sub-image
 * \param src_x_r
 *    horizontal index to "BOTTOM" source sub-image
 * \param src_y_r
 *    vertical index to "BOTTOM" source sub-image
 * \param offset
 *    offset (either +0 or +1) for BOTTOM sub-image VER coordinate
 ************************************************************************
 */
void getVerSubImageBiLinear( StorablePicture *s, int dst_y, int dst_x, int src_y_l, int src_x_l, int src_y_r, int src_x_r, int offset )
{
  int jpad;
  int ipad;
  int ypadded_size = s->size_y + 2 * IMG_PAD_SIZE;
  int xpadded_size = s->size_x + 2 * IMG_PAD_SIZE;
  int maxy = ypadded_size - 1;

  imgpel *wBufSrcL, *wBufSrcR, *wBufDst;
  int ypadded_size_top = maxy - offset;

  // top
  for (jpad = 0; jpad < ypadded_size_top; jpad++)
  {
    wBufSrcL = s->curr_imgY_sub[src_y_l][src_x_l][jpad];          // 4:4:4 independent mode
    wBufDst  = s->curr_imgY_sub[dst_y][dst_x][jpad];              // 4:4:4 independent mode
    wBufSrcR = s->curr_imgY_sub[src_y_r][src_x_r][jpad + offset]; // 4:4:4 independent mode

    for (ipad = 0; ipad < xpadded_size; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf(wBufSrcL[ipad] + wBufSrcR[ipad], 1);
    }
  }
  // bottom
  for (jpad = ypadded_size_top; jpad < ypadded_size; jpad++)
  {
    wBufSrcL = s->curr_imgY_sub[src_y_l][src_x_l][jpad];          // 4:4:4 independent mode
    wBufDst  = s->curr_imgY_sub[dst_y  ][dst_x  ][jpad];          // 4:4:4 independent mode
    wBufSrcR = s->curr_imgY_sub[src_y_r][src_x_r][maxy];          // 4:4:4 independent mode

    for (ipad = 0; ipad < xpadded_size; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf(wBufSrcL[ipad] + wBufSrcR[ipad], 1);
    }
  }
}


/*!
 ************************************************************************
 * \brief
 *    Does _diagonal_ interpolation using the BiLinear filter
 *
 * \param s
 *    pointer to StorablePicture structure
 * \param dst_x
 *    horizontal index to sub-image being generated
 * \param dst_y
 *    vertical index to sub-image being generated
 * \param src_x_l
 *    horizontal index to "TOP" source sub-image
 * \param src_y_l
 *    vertical index to "TOP" source sub-image
 * \param src_x_r
 *    horizontal index to "BOTTOM" source sub-image
 * \param src_y_r
 *    vertical index to "BOTTOM" source sub-image
 * \param offset_y_l
 *    Y offset (either +0 or +1) for TOP sub-image coordinate
 * \param offset_x_l
 *    X offset (either +0 or +1) for TOP sub-image coordinate
 * \param offset_y_r
 *    Y offset (either +0 or +1) for BOTTOM sub-image coordinate
 * \param offset_x_r
 *    X offset (either +0 or +1) for BOTTOM sub-image coordinate
 ************************************************************************
 */
void getDiagSubImageBiLinear( StorablePicture *s, int dst_y, int dst_x, int src_y_l, int src_x_l, int src_y_r, int src_x_r, int offset_y_l, int offset_x_l,
                             int offset_y_r, int offset_x_r )
{
  int jpad;
  int ipad;
  int ypadded_size = s->size_y + 2 * IMG_PAD_SIZE;
  int xpadded_size = s->size_x + 2 * IMG_PAD_SIZE;
  int maxx = xpadded_size - 1;
  int maxy = ypadded_size - 1;

  imgpel *wBufSrcL, *wBufSrcR, *wBufDst;
  // -1 explanation: offsets can be maximally one so let's assume the worst and avoid too many checks
  int ypadded_size_top = ypadded_size - IMG_PAD_SIZE - 1;

  for (jpad = 0; jpad < ypadded_size_top; jpad++)
  {
    wBufSrcL = s->curr_imgY_sub[src_y_l][src_x_l][jpad + offset_y_l]; // 4:4:4 independent mode
    wBufSrcR = s->curr_imgY_sub[src_y_r][src_x_r][jpad + offset_y_r]; // 4:4:4 independent mode
    wBufDst = s->curr_imgY_sub[dst_y][dst_x][jpad];                   // 4:4:4 independent mode

    for (ipad = 0; ipad < xpadded_size; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf(wBufSrcL[imin (maxx, ipad + offset_x_l)] +
        wBufSrcR[imin (maxx, ipad + offset_x_r)], 1);
    }
  }
  for (jpad = ypadded_size_top; jpad < ypadded_size; jpad++)
  {
    wBufSrcL = s->curr_imgY_sub[src_y_l][src_x_l][imin (maxy, jpad + offset_y_l)]; // 4:4:4 independent mode
    wBufSrcR = s->curr_imgY_sub[src_y_r][src_x_r][imin (maxy, jpad + offset_y_r)]; // 4:4:4 independent mode
    wBufDst = s->curr_imgY_sub[dst_y][dst_x][jpad];                                // 4:4:4 independent mode

    for (ipad = 0; ipad < xpadded_size; ipad++)
    {
      wBufDst[ipad] = (imgpel)
        rshift_rnd_sf(wBufSrcL[imin (maxx, ipad + offset_x_l)] +
        wBufSrcR[imin (maxx, ipad + offset_x_r)], 1);
    }
  }
}

⌨️ 快捷键说明

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