亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rdopt.c

?? h264標準的VC實現
?? C
?? 第 1 頁 / 共 5 頁
字號:

/*!
 ***************************************************************************
 * \file rdopt.c
 *
 * \brief
 *    Rate-Distortion optimized mode decision
 *
 * \author
 *    - Heiko Schwarz              <hschwarz@hhi.de>
 *    - Valeri George              <george@hhi.de>
 *    - Lowell Winger              <lwinger@lsil.com>
 *    - Alexis Michael Tourapis    <alexis@mobilygen.com>
 * \date
 *    12. April 2001
 **************************************************************************
 */

#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <limits.h>

#include "global.h"

#include "rdopt_coding_state.h"
#include "memalloc.h"
#include "mb_access.h"
#include "elements.h"
#include "intrarefresh.h"
#include "image.h"
#include "transform8x8.h"
#include "cabac.h"            // head file for rate control
#include "vlc.h"
#include "fast_me.h"
#include "ratectl.h"            // head file for rate control

#define KS_MV

//Rate control

int QP,QP2;
int DELTA_QP,DELTA_QP2;
int diffy[16][16];
static int pred[16][16];

extern       int  QP2QUANT  [40];

//==== MODULE PARAMETERS ====
int   best_mode;
imgpel   rec_mbY[16][16], rec_mbU[16][16], rec_mbV[16][16], rec_mbY8x8[16][16];    // reconstruction values
imgpel   mpr8x8[16][16];
int   ****cofAC=NULL, ****cofAC8x8=NULL;        // [8x8block][4x4block][level/run][scan_pos]
int   ***cofDC=NULL;                       // [yuv][level/run][scan_pos]
int   **cofAC4x4=NULL, ****cofAC4x4intern=NULL; // [level/run][scan_pos]
int   cbp, cbp8x8, cnt_nonz_8x8;
int64 cbp_blk;
int   cbp_blk8x8;
int   frefframe[4][4], brefframe[4][4], b8mode[4], b8pdir[4];
int   best8x8mode [4];                // [block]
int   best8x8pdir [MAXMODE][4];       // [mode][block]
int   best8x8fwref  [MAXMODE][4];       // [mode][block]
CSptr cs_mb=NULL, cs_b8=NULL, cs_cm=NULL, cs_imb=NULL, cs_ib8=NULL, cs_ib4=NULL, cs_pc=NULL;
int   best_c_imode;
int   best_i16offset;

int   best8x8bwref     [MAXMODE][4];       // [mode][block]
int   abp_typeframe[4][4];

imgpel temp_imgY[16][16]; // to temp store the Y data for 8x8 transform
imgpel temp_imgU[16][16];
imgpel temp_imgV[16][16];
int   best_transform_size[4];

//mixed transform sizes definitions
int   luma_transform_size_8x8_flag;
int   NoMbPartLessThan8x8Flag;

int part8x8pdir[4];
int part8x8fwref[4];
int part8x8bwref[4];

int mv8x8[2][4][4][2];              //[LIST][block_x][block_y][MVx/MVy]
int ref8x8[2][4][4];                //[LIST][block_x][block_y]

int all_mv8x8[2][2][4][4][2];       //[8x8_data/temp_data][LIST][block_x][block_y][MVx/MVy]
int pred_mv8x8[2][2][4][4][2];

//ADD-VG-28062004
int   ****cofAC_8x8ts = NULL;        // [8x8block][4x4block][level/run][scan_pos]
imgpel   rec_mbY_8x8ts[16][16];
imgpel   mpr_8x8ts[16][16];
int64    cbp_blk8_8x8ts;
int      cbp8_8x8ts;
int      cost8_8x8ts;
int      cnt_nonz8_8x8ts;
int      part8x8mode[4];
//ADD-VG-28062004-END


void StoreMV8x8(int dir);
void RestoreMV8x8(int dir);
// end of mixed transform sizes definitions


// Residue Color Transform
int   cofAC4x4_chroma[2][2][18];
int   rec_resG_8x8[16][16], resTrans_R_8x8[16][16], resTrans_B_8x8[16][16];
int   rec_resG_8x8ts[16][16], resTrans_R_8x8ts[16][16], resTrans_B_8x8ts[16][16];
int   mprRGB_8x8[3][16][16], mprRGB_8x8ts[3][16][16];
int   b4_ipredmode[16], b4_intra_pred_modes[16];

/*!
 ************************************************************************
 * \brief
 *    delete structure for RD-optimized mode decision
 ************************************************************************
 */
void clear_rdopt ()
{
  free_mem_DCcoeff (cofDC);
  free_mem_ACcoeff (cofAC);
  free_mem_ACcoeff (cofAC8x8);
  free_mem_ACcoeff (cofAC4x4intern);

  //ADD-VG-28062004
  if (input->AllowTransform8x8)
  {
    free_mem_ACcoeff (cofAC_8x8ts);
  }
  //ADD-VG-28062004-END
  
  // structure for saving the coding state
  delete_coding_state (cs_mb);
  delete_coding_state (cs_b8);
  delete_coding_state (cs_cm);
  delete_coding_state (cs_imb);
  delete_coding_state (cs_ib8);
  delete_coding_state (cs_ib4);
  delete_coding_state (cs_pc);
}


/*!
 ************************************************************************
 * \brief
 *    create structure for RD-optimized mode decision
 ************************************************************************
 */
void init_rdopt ()
{
  rdopt = NULL;

  get_mem_DCcoeff (&cofDC);
  get_mem_ACcoeff (&cofAC);
  get_mem_ACcoeff (&cofAC8x8);
  get_mem_ACcoeff (&cofAC4x4intern);
  cofAC4x4 = cofAC4x4intern[0][0];

  //ADD-VG-28062004
  if (input->AllowTransform8x8)
  {
    get_mem_ACcoeff (&cofAC_8x8ts);
  }
  //ADD-VG-28062004-END
  
  // structure for saving the coding state
  cs_mb  = create_coding_state ();
  cs_b8  = create_coding_state ();
  cs_cm  = create_coding_state ();
  cs_imb = create_coding_state ();
  cs_ib8 = create_coding_state ();
  cs_ib4 = create_coding_state ();
  cs_pc  = create_coding_state ();
}



/*!
 *************************************************************************************
 * \brief
 *    Updates the pixel map that shows, which reference frames are reliable for
 *    each MB-area of the picture.
 *
 * \note
 *    The new values of the pixel_map are taken from the temporary buffer refresh_map
 *
 *************************************************************************************
 */
void UpdatePixelMap()
{
  int mx,my,y,x,i,j;
  if (img->type==I_SLICE)
  {
    for (y=0; y<img->height; y++)
    for (x=0; x<img->width; x++)
    {
      pixel_map[y][x]=1;
    }
  }
  else
  {
    for (my=0; my<img->height/8; my++)
    for (mx=0; mx<img->width/8;  mx++)
    {
      j = my*8 + 8;
      i = mx*8 + 8;
      if (refresh_map[my][mx])
      {
        for (y=my*8; y<j; y++)
        for (x=mx*8; x<i; x++)  pixel_map[y][x] = 1;
      }
      else
      {
        for (y=my*8; y<j; y++)
        for (x=mx*8; x<i; x++)  pixel_map[y][x] = min(pixel_map[y][x]+1, input->num_ref_frames+1);
      }
    }
  }
}

/*!
 *************************************************************************************
 * \brief
 *    Checks if a given reference frame is reliable for the current
 *    macroblock, given the motion vectors that the motion search has
 *    returned.
 *
 * \return
 *    If the return value is 1, the reference frame is reliable. If it
 *    is 0, then it is not reliable.
 *
 * \note
 *    A specific area in each reference frame is assumed to be unreliable
 *    if the same area has been intra-refreshed in a subsequent frame.
 *    The information about intra-refreshed areas is kept in the pixel_map.
 *
 *************************************************************************************
 */
int CheckReliabilityOfRef (int block, int list_idx, int ref, int mode)
{
  int y,x, block_y, block_x, dy, dx, y_pos, x_pos, yy, xx, pres_x, pres_y;
  int maxold_x  = img->width-1;
  int maxold_y  = img->height-1;
  int ref_frame = ref+1;

  int by0 = (mode>=4?2*(block/2):mode==2?2*block:0);
  int by1 = by0 + (mode>=4||mode==2?2:4);
  int bx0 = (mode>=4?2*(block%2):mode==3?2*block:0);
  int bx1 = bx0 + (mode>=4||mode==3?2:4);

  for (block_y=by0; block_y<by1; block_y++)
    for (block_x=bx0; block_x<bx1; block_x++)
    {
      y_pos  = img->all_mv[block_x][block_y][list_idx][ref][mode][1];
      y_pos += (img->block_y+block_y) * BLOCK_SIZE * 4;
      x_pos  = img->all_mv[block_x][block_y][list_idx][ref][mode][0];
      x_pos += (img->block_x+block_x) * BLOCK_SIZE * 4;

      /* Here we specify which pixels of the reference frame influence
         the reference values and check their reliability. This is
         based on the function Get_Reference_Pixel */

      dy = y_pos & 3;
      dx = x_pos & 3;

      y_pos = (y_pos-dy)/4;
      x_pos = (x_pos-dx)/4;

      if (dy==0 && dx==0) //full-pel
      {
        for (y=0 ; y < BLOCK_SIZE ; y++)
          for (x=0 ; x < BLOCK_SIZE ; x++)
            if (pixel_map[max(0,min(maxold_y,y_pos+y))][max(0,min(maxold_x,x_pos+x))] < ref_frame)
              return 0;
      }
      else  /* other positions */
      {
        if (dy == 0)
        {
          for (y=0 ; y < BLOCK_SIZE ; y++)
            for (x=0 ; x < BLOCK_SIZE ; x++)
            {
              pres_y = max(0,min(maxold_y,y_pos+y));
              for(xx=-2;xx<4;xx++) {
                pres_x = max(0,min(maxold_x,x_pos+x+xx));
                if (pixel_map[pres_y][pres_x] < ref_frame)
                  return 0;
              }
            }
        }

        else if (dx == 0)
        {
          for (y=0 ; y < BLOCK_SIZE ; y++)
            for (x=0 ; x < BLOCK_SIZE ; x++)
            {
              pres_x = max(0,min(maxold_x,x_pos+x));
              for(yy=-2;yy<4;yy++) {
                pres_y = max(0,min(maxold_y,y_pos+yy+y));
                if (pixel_map[pres_y][pres_x] < ref_frame)
                  return 0;
              }
            }
        }
        else if (dx == 2)
        {
          for (y=0 ; y < BLOCK_SIZE ; y++)
            for (x=0 ; x < BLOCK_SIZE ; x++)
            {
              for(yy=-2;yy<4;yy++) {
                pres_y = max(0,min(maxold_y,y_pos+yy+y));
                for(xx=-2;xx<4;xx++) {
                  pres_x = max(0,min(maxold_x,x_pos+xx+x));
                  if (pixel_map[pres_y][pres_x] < ref_frame)
                    return 0;
                }
              }
            }
        }
        else if (dy == 2)
        {
          for (y=0 ; y < BLOCK_SIZE ; y++)
            for (x=0 ; x < BLOCK_SIZE ; x++)
            {
              for(xx=-2;xx<4;xx++) {
                pres_x = max(0,min(maxold_x,x_pos+xx+x));
                for(yy=-2;yy<4;yy++) {
                  pres_y = max(0,min(maxold_y,y_pos+yy+y));
                  if (pixel_map[pres_y][pres_x] < ref_frame)
                    return 0;
                }
              }
            }
        }
        else
        {
          for (y=0 ; y < BLOCK_SIZE ; y++)
            for (x=0 ; x < BLOCK_SIZE ; x++)
            {
              pres_y = dy == 1 ? y_pos+y : y_pos+y+1;
              pres_y = max(0,min(maxold_y,pres_y));

              for(xx=-2;xx<4;xx++) {
                pres_x = max(0,min(maxold_x,x_pos+xx+x));
                if (pixel_map[pres_y][pres_x] < ref_frame)
                  return 0;
              }

              pres_x = dx == 1 ? x_pos+x : x_pos+x+1;
              pres_x = max(0,min(maxold_x,pres_x));

              for(yy=-2;yy<4;yy++) {
                pres_y = max(0,min(maxold_y,y_pos+yy+y));
                if (pixel_map[pres_y][pres_x] < ref_frame)
                  return 0;
              }
            }
        }

      }
    }

  return 1;
}



/*!
 *************************************************************************************
 * \brief
 *    R-D Cost for an 4x4 Intra block
 *************************************************************************************
 */
double RDCost_for_4x4IntraBlocks (int*    nonzero,
                           int     b8,
                           int     b4,
                           int    ipmode,
                           double  lambda,
                           double  min_rdcost,
                           int mostProbableMode)
{
  double  rdcost;
  int     dummy, x, y, rate;
  int     distortion  = 0;
  int     block_x     = 8*(b8%2)+4*(b4%2);
  int     block_y     = 8*(b8/2)+4*(b4/2);
  int     pic_pix_x   = img->pix_x+block_x;
  int     pic_pix_y   = img->pix_y+block_y;
  int     pic_opix_y  = img->opix_y+block_y;
  imgpel  **imgY      = enc_picture->imgY;

  Slice          *currSlice    =  img->currentSlice;
  Macroblock     *currMB       = &img->mb_data[img->current_mb_nr];
  SyntaxElement  *currSE       = &img->MB_SyntaxElements[currMB->currSEnr];
  const int      *partMap      = assignSE2partition[input->partition_mode];
  DataPartition  *dataPart;

  //===== perform DCT, Q, IQ, IDCT, Reconstruction =====
  dummy = 0;

  *nonzero = dct_luma (block_x, block_y, &dummy, 1);

  //===== get distortion (SSD) of 4x4 block =====
  if(!img->residue_transform_flag)
  {
    for (y=0; y<4; y++)
    {
      for (x=pic_pix_x; x<pic_pix_x+4; x++)
      {
        distortion += img->quad [imgY_org[pic_opix_y+y][x] - imgY[pic_pix_y+y][x]];
      }
    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品一区二区www| 欧美日本免费一区二区三区| 日韩一区二区在线看片| 男女性色大片免费观看一区二区 | 国产精品一卡二卡| 国产欧美一区二区三区网站| 成人性视频网站| 一区二区在线观看不卡| 欧美吞精做爰啪啪高潮| 午夜日韩在线电影| 精品日韩一区二区三区免费视频| 国产精品亚洲成人| 中文字幕亚洲电影| 欧美另类久久久品| 国产尤物一区二区在线| 亚洲图片另类小说| 欧美精品一二三| 国产精品77777竹菊影视小说| 中文欧美字幕免费| 精品视频色一区| 国产一区二区三区电影在线观看| 中文字幕在线免费不卡| 欧美日韩国产高清一区| 国产精品一区一区| 亚洲永久免费av| 久久综合狠狠综合久久激情| 91在线视频播放| 精品中文字幕一区二区| 《视频一区视频二区| 在线电影国产精品| 不卡一区二区三区四区| 日韩精品一级二级| 中文字幕日韩av资源站| 欧美一区二区三区在线视频| 国产福利一区二区三区视频 | 69堂成人精品免费视频| 国产精品1区二区.| 五月婷婷久久丁香| 中文成人综合网| 精品三级在线看| 欧美一a一片一级一片| 国产精品亚洲а∨天堂免在线| 亚洲成人第一页| 国产精品第13页| 精品成人在线观看| 欧美日韩美少妇| 色综合天天综合在线视频| 国产精品一级黄| 麻豆久久久久久久| 亚洲综合另类小说| 中文字幕视频一区| 国产欧美精品一区二区三区四区| 日韩一区二区三区av| 欧美丝袜丝交足nylons| 波多野洁衣一区| 国产精品性做久久久久久| 美女尤物国产一区| 天天操天天综合网| 亚洲永久精品大片| 一卡二卡三卡日韩欧美| 综合久久一区二区三区| 国产色产综合产在线视频| 日韩欧美一级在线播放| 在线播放中文字幕一区| 欧美日本一区二区在线观看| 色婷婷综合五月| 91一区在线观看| 99精品一区二区三区| 懂色一区二区三区免费观看| 国产精品中文字幕欧美| 国产在线精品国自产拍免费| 久久精品免费观看| 另类小说一区二区三区| 久久精品久久99精品久久| 麻豆成人av在线| 精品一区二区三区免费播放| 蜜桃久久av一区| 免费黄网站欧美| 久久99精品久久久久久久久久久久 | 欧美午夜精品久久久久久超碰| 91在线一区二区三区| 色天天综合久久久久综合片| 色综合视频在线观看| 色噜噜狠狠成人网p站| 在线观看一区二区视频| 欧美午夜在线观看| 91精品国产综合久久精品性色| 欧美片网站yy| 欧美v日韩v国产v| 久久精品男人天堂av| 国产精品电影院| 亚洲一区免费视频| 日本欧美一区二区在线观看| 麻豆国产精品视频| 成人黄色大片在线观看| 色婷婷国产精品| 欧美美女直播网站| 欧美精品一区二区三区四区| 国产清纯美女被跳蛋高潮一区二区久久w| 国产欧美日韩精品a在线观看| 综合av第一页| 婷婷久久综合九色综合伊人色| 久久成人精品无人区| 丁香婷婷综合色啪| 欧美亚洲综合色| 欧美精品一区二区三区蜜臀| 中文字幕一区二区三| 亚洲福利一区二区三区| 韩国av一区二区| 色诱亚洲精品久久久久久| 欧美精品丝袜久久久中文字幕| 久久这里只有精品6| 亚洲视频1区2区| 麻豆91精品91久久久的内涵| 波多野结衣欧美| 精品久久人人做人人爽| 亚洲三级免费电影| 日本不卡的三区四区五区| 99久久精品国产网站| 日韩欧美一区二区不卡| |精品福利一区二区三区| 日韩av网站在线观看| 成人av资源下载| 日韩美女天天操| 悠悠色在线精品| 福利电影一区二区三区| 91精品在线免费观看| 日韩一区中文字幕| 看电影不卡的网站| 欧美喷水一区二区| 亚洲人精品午夜| 国产精品91xxx| 日韩视频一区二区三区在线播放| 亚洲人一二三区| 国产成人一区二区精品非洲| 欧美日韩国产综合久久| 一区在线观看视频| 国产精品99久| 日韩欧美你懂的| 视频一区国产视频| 欧美主播一区二区三区| 中文字幕欧美国产| 国产一区在线视频| 日韩免费看的电影| 图片区小说区区亚洲影院| 91视频免费播放| 国产精品传媒视频| 国产成人8x视频一区二区| 欧美成人性战久久| 男男成人高潮片免费网站| 在线观看免费亚洲| 亚洲男同1069视频| 94-欧美-setu| 亚洲私人影院在线观看| 成人福利视频网站| 欧美三级中文字幕| 日韩黄色免费网站| 色婷婷综合久久久中文一区二区| 久久综合九色综合97_久久久| 免费精品视频在线| 91精品福利在线一区二区三区| 亚洲主播在线观看| 色av成人天堂桃色av| 成人欧美一区二区三区| 北条麻妃国产九九精品视频| 国产精品免费看片| 94-欧美-setu| 亚洲精品国产品国语在线app| 91视频国产观看| 亚洲一区二区三区四区在线| 色爱区综合激月婷婷| 亚洲国产成人91porn| 欧美日韩国产综合久久| 青青草97国产精品免费观看| 91精品一区二区三区在线观看| 青青草成人在线观看| 亚洲精品一区二区三区蜜桃下载| 久久精品99国产精品| 久久亚洲一区二区三区四区| 国产精品1区二区.| 亚洲色图制服诱惑| 欧美日韩国产区一| 久久成人免费日本黄色| 久久久久久一二三区| 成人高清免费观看| 一区二区三区成人| 欧美一区二区在线视频| 国产自产视频一区二区三区| 国产亚洲综合色| 91麻豆精品在线观看| 日韩电影一区二区三区四区| 精品成人在线观看| 99热精品国产| 丝袜美腿亚洲色图| 精品免费一区二区三区| 不卡视频一二三四| 日韩电影在线免费观看| 国产精品欧美经典| 欧美日韩大陆一区二区| 国产成人三级在线观看|