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

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

?? weighted_prediction.c

?? 一個簡單的視頻會議VC++MFC工程文件
?? C
字號:

/*!
*************************************************************************************
* \file weighted_prediction.c
*
* \brief
*    Estimate weights for WP
*
* \author
*    Main contributors (see contributors.h for copyright, address and affiliation details)
*     - Alexis Michael Tourapis         <alexismt@ieee.org>
*************************************************************************************
*/
#include <stdlib.h>
#include "contributors.h"

#include "global.h"

#include "image.h"

/*!
************************************************************************
* \brief
*    Estimates reference picture weighting factors
************************************************************************
*/

void estimate_weighting_factor_P_slice(int select_offset)
{
  int i, j, n;
  
  double dc_org = 0.0;
  int index;
  int comp;
  double dc_ref[MAX_REFERENCE_PICTURES];
  
  pel_t*  ref_pic;   
  pel_t*  ref_pic_w;   
  int default_weight;
  int default_weight_chroma;
  int list_offset   = ((img->MbaffFrameFlag)&&(img->mb_data[img->current_mb_nr].mb_field))? img->current_mb_nr%2 ? 4 : 2 : 0;
  int weight[2][MAX_REFERENCE_PICTURES][3]; 
  int offset[2][MAX_REFERENCE_PICTURES][3];       
  int clist;
  
  
  
  luma_log_weight_denom = 5;
  chroma_log_weight_denom = 5;
  wp_luma_round = 1 << (luma_log_weight_denom - 1);
  wp_chroma_round = 1 << (chroma_log_weight_denom - 1);
  default_weight = 1<<luma_log_weight_denom;
  default_weight_chroma = 1<<chroma_log_weight_denom;
  
  /* set all values to defaults */
  for (i = 0; i < 2 + list_offset; i++)
  {
    for (j = 0; j < listXsize[i]; j++)
    {
      for (n = 0; n < 3; n++)
      {
        weight[i][j][n] = default_weight;
        wp_weight[i][j][n] = default_weight;
        wp_offset[i][j][n] = 0;
        offset[i][j][n] = 0;
      }
    }
  }
  
  for (i = 0; i < img->height; i++)
  {
    for (j = 0; j < img->width; j++)
    {
      dc_org += (double) imgY_org[i][j];
    }
  } 
    
  for (clist=0; clist<2 + list_offset; clist++)
  {
    for (n = 0; n < listXsize[clist]; n++)
    {
      dc_ref[n] = 0.0;
      
      ref_pic       = listX[clist][n]->imgY_11;
      ref_pic_w     = listX[clist][n]->imgY_11_w;
      
      // Y
      for (i = 0; i < img->height * img->width; i++)
      {
        dc_ref[n] += (double) ref_pic[i];
      }
      
      if (select_offset==0)
      {
        if (dc_ref[n] != 0)
          weight[clist][n][0] = (int) (default_weight * dc_org / dc_ref[n] + 0.5);
        else
          weight[clist][n][0] = default_weight;  // only used when reference picture is black
        if (weight[clist][n][0] < -64 || weight[clist][n][0] >127)
          weight[clist][n][0] = 32;
      }
      else
      {        
        offset[clist][n][0] = (int) ((dc_org-dc_ref[n])/(img->height*img->width)+0.5);
        //printf("offset[clist][%d][0] %d %.2f %.2f\n",n,offset[clist][n][0], dc_org,dc_ref[n] );
        offset[clist][n][0] = (offset[clist][n][0]<-128) ? -128: (offset[clist][n][0]>127) ? 127:offset[clist][n][0];
        weight[clist][n][0] = default_weight;
      }
      
      
      /* for now always use default weight for chroma weight */
      weight[clist][n][1] = default_weight_chroma;
      weight[clist][n][2] = default_weight_chroma;
      
      
      
      /* store weighted reference pic for motion estimation */
      for (i = 0; i < img->height * img->width; i++)
      {          
        ref_pic_w[i] = Clip3 (0, img->max_imgpel_value , (((int) ref_pic[i] * weight[clist][n][0] + wp_luma_round) >> luma_log_weight_denom) + offset[clist][n][0]);
      }
      for (i = 0; i < 4*(img->height + 2*IMG_PAD_SIZE) ; i++)
      {
        for (j = 0; j< 4*(img->width + 2*IMG_PAD_SIZE); j++)
        {
          listX[LIST_0][n]->imgY_ups_w[i][j] =   Clip3 (0, img->max_imgpel_value, (((int) listX[LIST_0 ][n]->imgY_ups[i][j] * weight[clist][n][0] + wp_luma_round) >> luma_log_weight_denom) + offset[clist][n][0]);
        }
      }
    }
  }
  
  for (clist=0; clist<2 + list_offset; clist++)
  {
    for (index = 0; index < listXsize[clist]; index++)
    {
      for (comp=0; comp < 3; comp ++)
      {
        wp_weight[0][index][comp] = weight[0][index][comp];
        wp_offset[0][index][comp] = offset[0][index][comp];
        // printf("index %d component %d weight %d offset %d\n",index,comp,weight[0][index][comp],offset[0][index][comp]);
      }
    }
  }
  
}

/*!
************************************************************************
* \brief
*    Estimates reference picture weighting factors
************************************************************************
*/
void estimate_weighting_factor_B_slice()
{
  int i, j, n, l;
  
  int tx,DistScaleFactor;
  double dc_org = 0.0;
  int index;
  int comp;
  double dc_ref[6][MAX_REFERENCE_PICTURES];
  
  int log_weight_denom;
  
  pel_t*  ref_pic;   
  pel_t*  ref_pic_w;   
  int default_weight;
  int default_weight_chroma;
  int list_offset   = ((img->MbaffFrameFlag)&&(img->mb_data[img->current_mb_nr].mb_field))? img->current_mb_nr%2 ? 4 : 2 : 0;
  int weight[6][MAX_REFERENCE_PICTURES][3]; 
  int offset[6][MAX_REFERENCE_PICTURES][3];       
  int im_weight[6][MAX_REFERENCE_PICTURES][MAX_REFERENCE_PICTURES][3]; 
  int im_offset[6][MAX_REFERENCE_PICTURES][MAX_REFERENCE_PICTURES][3]; 
  int clist;
  int wf_weight, wf_offset;
  
  luma_log_weight_denom = 5;
  chroma_log_weight_denom = 5;
  wp_luma_round = 1 << (luma_log_weight_denom - 1);
  wp_chroma_round = 1 << (chroma_log_weight_denom - 1);
  default_weight = 1<<luma_log_weight_denom;
  default_weight_chroma = 1<<chroma_log_weight_denom;
  
  /* set all values to defaults */
  for (i = 0; i < 2 + list_offset; i++)
  {
    for (j = 0; j < listXsize[i]; j++)
    {
      for (n = 0; n < 3; n++)
      {
        wp_weight[i][j][n] = default_weight;
        wp_offset[i][j][n] = 0;
        offset   [i][j][n] = 0;
        weight   [i][j][n] = default_weight;
      }
    }
  }
  
  for (i = 0; i < listXsize[LIST_0]; i++)
  {
    for (j = 0; j < listXsize[LIST_1]; j++)
    {
      int td, tb;
      td = Clip3(-128,127,(listX[LIST_1][j]->poc - listX[LIST_0][i]->poc));
      tb = Clip3(-128,127,(enc_picture->poc - listX[LIST_0][i]->poc));
      for (comp = 0; comp < 3; comp++)
      {
        // implicit weights          
        if (td == 0)
        {
          im_weight[1][i][j][comp] = 32 ;
          im_weight[0][i][j][comp] = 32;
          im_offset[1][i][j][comp] = 0;
          im_offset[0][i][j][comp] = 0;
        }
        else
        {            
          tx = (16384 + abs(td/2))/td;
          DistScaleFactor = Clip3(-1024, 1023, (tx*tb + 32 )>>6);
          im_weight[1][i][j][comp] = DistScaleFactor>>2;
          if (im_weight[1][i][j][comp] < -64 || im_weight[1][i][j][comp] >128)
            im_weight[1][i][j][comp] = 32;
          im_weight[0][i][j][comp] = 64 - im_weight[1][i][j][comp];            
          im_offset[1][i][j][comp] = 0;
          im_offset[0][i][j][comp] = 0;
        }        
      }
      /*
      printf ("%d imp weight[%d][%d] = %d  , %d (%d %d %d) (%d %d) (%d %d)\n",enc_picture->poc, i, j,  im_weight[0][i][j][0], im_weight[1][i][j][0],
        enc_picture->poc,listX[LIST_0][i]->poc, listX[LIST_1][j]->poc,
        DistScaleFactor ,tx,td,tb);
      */
    }
  }
  
  
  if (active_pps->weighted_bipred_idc == 2) //! implicit mode
  {
    
    for (i = 0; i < listXsize[LIST_0]; i++)
    {
      for (j = 0; j < listXsize[LIST_1]; j++)
      {
        for (comp = 0; comp < 3; comp++)
        {
          log_weight_denom = (comp == 0) ? luma_log_weight_denom : chroma_log_weight_denom;         
          wbp_weight[1][i][j][comp] = im_weight[1][i][j][comp] ;
          wbp_weight[0][i][j][comp] = im_weight[0][i][j][comp];
        }
      }
    }
    
    for (clist=0; clist<2 + list_offset; clist++)
    {
      for (index = 0; index < listXsize[clist]; index++)
      {
        wp_weight[clist][index][0] = 1<<luma_log_weight_denom;
        wp_weight[clist][index][1] = 1<<chroma_log_weight_denom;
        wp_weight[clist][index][2] = 1<<chroma_log_weight_denom;
        wp_offset[clist][index][0] = 0;
        wp_offset[clist][index][1] = 0;
        wp_offset[clist][index][2] = 0;
      }
    }
    for (i = 0; i < listXsize[LIST_0]; i++)
    {
      for (j = 0; j < listXsize[LIST_1]; j++)
      {
        
        for (n = 0; n < img->height * img->width; n++)
        {
          listX[0][i]->imgY_11_w[n] = listX[0][i]->imgY_11[n];
          listX[1][j]->imgY_11_w[n] = listX[1][j]->imgY_11[n];
        }
        
        for (n = 0; n < 4*(img->height + 2*IMG_PAD_SIZE) ; n++)
        {
          for (l = 0; l< 4*(img->width + 2*IMG_PAD_SIZE); l++)
          {
            listX[LIST_0][i]->imgY_ups_w[n][l] =   listX[LIST_0 ][i]->imgY_ups[n][l];
            listX[LIST_1][j]->imgY_ups_w[n][l] =   listX[LIST_1 ][j]->imgY_ups[n][l];
          }
        }
      }
    }
  }
  else
  {
    for (i = 0; i < img->height; i++)
    {
      for (j = 0; j < img->width; j++)
      {
        dc_org += (double) imgY_org[i][j];
      }
    }
    
    for (clist=0; clist<2 + list_offset; clist++)
    {
      for (n = 0; n < listXsize[clist]; n++)
      {
        dc_ref[clist][n] = 0;
        
        ref_pic       = listX[clist][n]->imgY_11;
        ref_pic_w     = listX[clist][n]->imgY_11_w;
        
        // Y
        for (i = 0; i < img->height * img->width; i++)
        {
          dc_ref[clist][n] += (double) ref_pic[i];
        }
        if (dc_ref[clist][n] != 0)
          wf_weight = (int) (default_weight * dc_org / dc_ref[clist][n] + 0.5);
        else
          wf_weight = default_weight;  // only used when reference picture is black
        if ( (wf_weight<-64) || (wf_weight>127) )
        {
          wf_weight = default_weight;
        }
        wf_offset = 0;
        
        
        //    printf("dc_org = %d, dc_ref = %d, weight[%d] = %d\n",dc_org, dc_ref[n],n,weight[n][0]);        
        
        weight[clist][n][0] = wf_weight;
        weight[clist][n][1] = default_weight_chroma;
        weight[clist][n][2] = default_weight_chroma;
        offset[clist][n][0] = 0;
        offset[clist][n][1] = 0;
        offset[clist][n][2] = 0;
        
        
        /* store weighted reference pic for motion estimation */
        for (i = 0; i < img->height * img->width; i++)
        {
          ref_pic_w[i] = Clip3 (0, img->max_imgpel_value, (((int) ref_pic[i] * wf_weight + wp_luma_round) >> luma_log_weight_denom) + wf_offset);
        }
        for (i = 0; i < 4*(img->height + 2*IMG_PAD_SIZE) ; i++)
        {
          for (j = 0; j< 4*(img->width + 2*IMG_PAD_SIZE); j++)
          {
            listX[LIST_0][n]->imgY_ups_w[i][j] =   Clip3 (0, img->max_imgpel_value, (((int) listX[LIST_0][n]->imgY_ups[i][j] * wf_weight + wp_luma_round) >> (luma_log_weight_denom)) + wf_offset );      	
          }
          
        }
      }
    }
    
    if (active_pps->weighted_bipred_idc == 1)
    {
      for (clist=0; clist<2 + list_offset; clist++)
      {
        for (index = 0; index < listXsize[clist]; index++)
        {
          for (comp = 0; comp < 3; comp++)
          {
            wp_weight[clist][index][comp] = weight[clist][index][comp];
            wp_offset[clist][index][comp] = offset[clist][index][comp];
            //printf("%d %d\n",wp_weight[clist][index][comp],wp_offset[clist][index][comp]);
          }
        }
      }
    }
    else
    {    
      for (clist=0; clist<2 + list_offset; clist++)
      {
        for (index = 0; index < listXsize[clist]; index++)
        {
          wp_weight[clist][index][0] = 1<<luma_log_weight_denom;
          wp_weight[clist][index][1] = 1<<chroma_log_weight_denom;
          wp_weight[clist][index][2] = 1<<chroma_log_weight_denom;
          wp_offset[clist][index][0] = 0;
          wp_offset[clist][index][1] = 0;
          wp_offset[clist][index][2] = 0;
        }
      }
    }
    for (i = 0; i < listXsize[LIST_0]; i++)
    {
      for (j = 0; j < listXsize[LIST_1]; j++)
      {
        for (comp = 0; comp < 3; comp++)
        {
          log_weight_denom = (comp == 0) ? luma_log_weight_denom : chroma_log_weight_denom;
          wbp_weight[0][i][j][comp] = wp_weight[0][i][comp];
          wbp_weight[1][i][j][comp] = wp_weight[1][j][comp];
        }
        /*
        printf ("bpw weight[%d][%d] = %d  , %d (%d %d %d) (%d %d) (%d %d)\n", i, j, wbp_weight[0][i][j][0], wbp_weight[1][i][j][0],
          enc_picture->poc,listX[LIST_0][i]->poc, listX[LIST_1][j]->poc,
          DistScaleFactor ,tx,tx,tx);
        */
      }
    }    
  }
}
    
    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区免费看| 麻豆91在线看| 日韩av在线免费观看不卡| 免费看精品久久片| 粉嫩一区二区三区在线看| 91在线视频免费观看| 欧美精品v日韩精品v韩国精品v| 欧美一级专区免费大片| 国产精品视频免费| 亚洲一区二区三区四区在线观看 | 欧美在线小视频| 欧美一区欧美二区| 国产精品久久久久久妇女6080| 一二三区精品视频| 国产一区二区三区精品欧美日韩一区二区三区| 成人av网址在线| 欧美一区二区精品久久911| 国产亚洲一区二区在线观看| 亚洲福利视频导航| 成人国产亚洲欧美成人综合网| 91精品国产综合久久精品app| 中文字幕中文字幕一区二区| 亚洲电影你懂得| 麻豆精品精品国产自在97香蕉| 91网站在线播放| 欧美精品v国产精品v日韩精品| 17c精品麻豆一区二区免费| 久久成人18免费观看| 欧美性一二三区| 国产精品乱码一区二区三区软件| 美女久久久精品| 欧美区一区二区三区| 亚洲蜜臀av乱码久久精品蜜桃| 国产jizzjizz一区二区| 久久夜色精品国产噜噜av| 秋霞电影一区二区| 欧美日韩国产综合草草| 中文字幕av不卡| 久久99精品久久久久久动态图| 欧美男男青年gay1069videost | 日韩欧美中文字幕精品| 亚洲激情图片qvod| caoporn国产精品| 欧美mv日韩mv国产网站| 午夜av区久久| 欧美日韩视频在线观看一区二区三区| 国产精品高潮呻吟| 国产成人av电影在线| 国产女人aaa级久久久级| 韩国精品免费视频| 久久婷婷成人综合色| 久久精品国产77777蜜臀| 日韩一级免费观看| 日韩精品午夜视频| 在线不卡免费av| 免费久久99精品国产| 在线播放日韩导航| 蜜臀av性久久久久蜜臀av麻豆 | 欧美成人精品二区三区99精品| 亚洲国产成人91porn| 欧美日韩免费视频| 美腿丝袜亚洲一区| 欧美精品一区视频| 国产成人免费视频网站| 中文字幕在线播放不卡一区| 99国产精品国产精品毛片| 欧美巨大另类极品videosbest | 国产成人在线观看免费网站| xvideos.蜜桃一区二区| 国产成人在线观看| 中文字幕一区免费在线观看| 色婷婷一区二区三区四区| 亚洲午夜av在线| 色综合久久天天综合网| 亚洲综合色婷婷| 欧美精品久久天天躁| 日本不卡的三区四区五区| 国产日韩欧美a| 欧洲精品在线观看| 七七婷婷婷婷精品国产| 欧美国产精品久久| 欧美三级中文字幕在线观看| 精品在线你懂的| 亚洲视频在线一区| 欧美一区二区三区视频| 国产suv精品一区二区883| 国产日产欧美一区| 97久久精品人人爽人人爽蜜臀| 亚洲激情成人在线| 欧美日韩亚洲另类| 成人午夜电影小说| 午夜精品久久久久久久久| 久久精品一区蜜桃臀影院| 色综合久久66| 国产一区亚洲一区| 亚洲超丰满肉感bbw| 欧美国产丝袜视频| 91麻豆精品国产91久久久使用方法| 国产精品白丝av| 无码av中文一区二区三区桃花岛| 国产欧美一区视频| 777久久久精品| 国产精品一区二区果冻传媒| 亚洲主播在线观看| 久久日韩粉嫩一区二区三区| 欧美影视一区在线| 国产精品一区二区视频| 亚洲国产成人91porn| 亚洲欧洲性图库| 久久精品人人做人人综合| 777久久久精品| 精品视频色一区| 97se亚洲国产综合自在线| 国内精品嫩模私拍在线| 日韩不卡一区二区| 亚洲观看高清完整版在线观看| 中文字幕乱码亚洲精品一区| 欧美亚洲一区二区三区四区| 国产在线精品免费| 亚洲国产精品久久人人爱蜜臀| 中文字幕视频一区二区三区久| 久久精品夜色噜噜亚洲aⅴ| 日韩欧美成人午夜| 91精品欧美福利在线观看| 欧美三级韩国三级日本一级| 欧洲视频一区二区| 91国产成人在线| 91免费精品国自产拍在线不卡 | 成人美女视频在线观看18| 韩国av一区二区三区在线观看| 免费av成人在线| 日韩国产欧美一区二区三区| 午夜欧美大尺度福利影院在线看| 亚洲午夜免费福利视频| 亚洲一区二区欧美| 亚洲色图欧美激情| 亚洲精品乱码久久久久| 亚洲黄色av一区| 亚洲高清免费观看高清完整版在线观看| 亚洲理论在线观看| 亚洲亚洲人成综合网络| 亚洲福中文字幕伊人影院| 午夜精品一区二区三区免费视频| 午夜精品一区二区三区电影天堂| 亚瑟在线精品视频| 日韩精品一卡二卡三卡四卡无卡 | 91国产视频在线观看| 欧美系列日韩一区| 91精品综合久久久久久| 精品久久人人做人人爰| 国产欧美精品一区二区色综合 | 99r国产精品| 97久久人人超碰| 91黄色激情网站| 91福利在线看| 欧美性色黄大片| 欧美日韩国产一二三| 777奇米成人网| 久久久久9999亚洲精品| 国产精品久久毛片| 亚洲一区二区三区四区的| 免费在线成人网| 国产不卡高清在线观看视频| 色婷婷久久一区二区三区麻豆| 在线不卡免费欧美| 欧美国产欧美综合| 婷婷综合另类小说色区| 国产资源精品在线观看| www.色综合.com| 91精品欧美一区二区三区综合在| 国产亚洲成年网址在线观看| 中文字幕一区二区三区不卡在线| 亚洲电影激情视频网站| 蜜桃在线一区二区三区| 国产一区二区精品在线观看| 91丨porny丨户外露出| 欧美色精品天天在线观看视频| 欧美不卡视频一区| 国产精品麻豆一区二区| 亚洲丰满少妇videoshd| 国产一区二区三区四区在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 欧美一区二区在线免费播放| 一区精品在线播放| 日韩国产欧美三级| 色综合天天综合在线视频| 精品国产一区二区三区久久久蜜月| 最新不卡av在线| 国产精品亚洲一区二区三区妖精 | 国产aⅴ综合色| 欧美视频在线播放| 中文无字幕一区二区三区| 免费不卡在线视频| 欧美性生交片4| 日韩美女啊v在线免费观看| 久久av中文字幕片| 欧美主播一区二区三区| 国产精品伦理一区二区| 国产综合久久久久久久久久久久| 91麻豆精品91久久久久同性|