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

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

?? cabac.c

?? 一個簡單的視頻會議VC++MFC工程文件
?? C
?? 第 1 頁 / 共 4 頁
字號:

/*!
 *************************************************************************************
 * \file cabac.c
 *
 * \brief
 *    CABAC entropy coding routines
 *
 * \author
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
 *    - Detlev Marpe                    <marpe@hhi.de>
 **************************************************************************************
 */

#include <stdlib.h>
#include <string.h>

#include "global.h"
#include "cabac.h"
#include "memalloc.h"
#include "elements.h"
#include "image.h"
#include "biaridecod.h"
#include "mb_access.h"

int symbolCount = 0;
int last_dquant = 0;


/***********************************************************************
 * L O C A L L Y   D E F I N E D   F U N C T I O N   P R O T O T Y P E S
 ***********************************************************************
 */
unsigned int unary_bin_decode(DecodingEnvironmentPtr dep_dp,
                              BiContextTypePtr ctx,
                              int ctx_offset);


unsigned int unary_bin_max_decode(DecodingEnvironmentPtr dep_dp,
                                  BiContextTypePtr ctx,
                                  int ctx_offset,
                                  unsigned int max_symbol);

unsigned int unary_exp_golomb_level_decode( DecodingEnvironmentPtr dep_dp,
                                            BiContextTypePtr ctx);

unsigned int unary_exp_golomb_mv_decode(DecodingEnvironmentPtr dep_dp,
                                        BiContextTypePtr ctx,
                                        unsigned int max_bin);


void CheckAvailabilityOfNeighborsCABAC()
{
  Macroblock *currMB = &img->mb_data[img->current_mb_nr];
  PixelPos up, left;

  getNeighbour(img->current_mb_nr, -1,  0, 1, &left);
  getNeighbour(img->current_mb_nr,  0, -1, 1, &up);
  
  if (up.available)
    currMB->mb_available_up = &img->mb_data[up.mb_addr];
  else
    currMB->mb_available_up = NULL;
  
  if (left.available)
    currMB->mb_available_left = &img->mb_data[left.mb_addr];
  else
    currMB->mb_available_left = NULL;
}

void cabac_new_slice()
{
  last_dquant=0;
}

/*!
 ************************************************************************
 * \brief
 *    Allocation of contexts models for the motion info
 *    used for arithmetic decoding
 *
 ************************************************************************
 */
MotionInfoContexts* create_contexts_MotionInfo(void)
{
  MotionInfoContexts *deco_ctx;

  deco_ctx = (MotionInfoContexts*) calloc(1, sizeof(MotionInfoContexts) );
  if( deco_ctx == NULL )
    no_mem_exit("create_contexts_MotionInfo: deco_ctx");

  return deco_ctx;
}


/*!
 ************************************************************************
 * \brief
 *    Allocates of contexts models for the texture info
 *    used for arithmetic decoding
 ************************************************************************
 */
TextureInfoContexts* create_contexts_TextureInfo(void)
{
  TextureInfoContexts *deco_ctx;

  deco_ctx = (TextureInfoContexts*) calloc(1, sizeof(TextureInfoContexts) );
  if( deco_ctx == NULL )
    no_mem_exit("create_contexts_TextureInfo: deco_ctx");

  return deco_ctx;
}




/*!
 ************************************************************************
 * \brief
 *    Frees the memory of the contexts models
 *    used for arithmetic decoding of the motion info.
 ************************************************************************
 */
void delete_contexts_MotionInfo(MotionInfoContexts *deco_ctx)
{
  if( deco_ctx == NULL )
    return;

  free( deco_ctx );

  return;
}


/*!
 ************************************************************************
 * \brief
 *    Frees the memory of the contexts models
 *    used for arithmetic decoding of the texture info.
 ************************************************************************
 */
void delete_contexts_TextureInfo(TextureInfoContexts *deco_ctx)
{
  if( deco_ctx == NULL )
    return;

  free( deco_ctx );

  return;
}

void readFieldModeInfo_CABAC( SyntaxElement *se,
                              struct inp_par *inp,
                              struct img_par *img,
                              DecodingEnvironmentPtr dep_dp)
{
  int a,b,act_ctx;
  MotionInfoContexts *ctx         = (img->currentSlice)->mot_ctx;
  Macroblock         *currMB      = &img->mb_data[img->current_mb_nr];
  
  if (currMB->mbAvailA)
    a = img->mb_data[currMB->mbAddrA].mb_field;
  else
    a = 0;
  if (currMB->mbAvailB)
    b = img->mb_data[currMB->mbAddrB].mb_field;
  else
    b=0;

  act_ctx = a + b;

  se->value1 = biari_decode_symbol (dep_dp, &ctx->mb_aff_contexts[act_ctx]);

#if TRACE
  fprintf(p_trace, "@%d %s\t\t%d\n",symbolCount++, se->tracestring, se->value1);
  fflush(p_trace);
#endif
}


int check_next_mb_and_get_field_mode_CABAC( SyntaxElement *se,
                                            struct img_par *img,
                                            struct inp_par *inp,
                                            DataPartition  *act_dp)
{
  BiContextTypePtr          mb_type_ctx_copy[4];
  BiContextTypePtr          mb_aff_ctx_copy;
  DecodingEnvironmentPtr    dep_dp_copy;

  int length;
  DecodingEnvironmentPtr    dep_dp = &(act_dp->de_cabac);

  int bframe = (img->type==B_SLICE);
  int skip   = 0;
  int field  = 0;
  int i;

  Macroblock *currMB;
  
  //get next MB
  img->current_mb_nr++;

  currMB = &img->mb_data[img->current_mb_nr];
  currMB->slice_nr = img->current_slice_nr;
  currMB->mb_field = img->mb_data[img->current_mb_nr-1].mb_field;

  CheckAvailabilityOfNeighbors();
  CheckAvailabilityOfNeighborsCABAC();
    
  //create
  dep_dp_copy = (DecodingEnvironmentPtr) calloc(1, sizeof(DecodingEnvironment) );
  for (i=0;i<4;i++)
    mb_type_ctx_copy[i] = (BiContextTypePtr) calloc(NUM_MB_TYPE_CTX, sizeof(BiContextType) );
  mb_aff_ctx_copy = (BiContextTypePtr) calloc(NUM_MB_AFF_CTX, sizeof(BiContextType) );
  
  //copy
  memcpy(dep_dp_copy,dep_dp,sizeof(DecodingEnvironment));
  length = *(dep_dp_copy->Dcodestrm_len) = *(dep_dp->Dcodestrm_len);
  for (i=0;i<4;i++)
    memcpy(mb_type_ctx_copy[i], img->currentSlice->mot_ctx->mb_type_contexts[i],NUM_MB_TYPE_CTX*sizeof(BiContextType) );
  memcpy(mb_aff_ctx_copy, img->currentSlice->mot_ctx->mb_aff_contexts,NUM_MB_AFF_CTX*sizeof(BiContextType) );


  //check_next_mb
#if TRACE
  strncpy(se->tracestring, "mb_skip_flag (of following bottom MB)", TRACESTRING_SIZE);
#endif
  last_dquant = 0;
  readMB_skip_flagInfo_CABAC(se,inp,img,dep_dp);

  skip = (bframe)? (se->value1==0 && se->value2==0) : (se->value1==0);
  if (!skip)
  {
#if TRACE
    strncpy(se->tracestring, "mb_field_decoding_flag (of following bottom MB)", TRACESTRING_SIZE);
#endif
    readFieldModeInfo_CABAC( se,inp,img,dep_dp);
    field = se->value1;
    img->mb_data[img->current_mb_nr-1].mb_field = field;
  }

  //reset
  img->current_mb_nr--;

  memcpy(dep_dp,dep_dp_copy,sizeof(DecodingEnvironment));
  *(dep_dp->Dcodestrm_len) = length;
  for (i=0;i<4;i++)
    memcpy(img->currentSlice->mot_ctx->mb_type_contexts[i],mb_type_ctx_copy[i], NUM_MB_TYPE_CTX*sizeof(BiContextType) );
  memcpy( img->currentSlice->mot_ctx->mb_aff_contexts,mb_aff_ctx_copy,NUM_MB_AFF_CTX*sizeof(BiContextType) );

  CheckAvailabilityOfNeighborsCABAC();
  
  //delete
  free(dep_dp_copy);
  for (i=0;i<4;i++)
    free(mb_type_ctx_copy[i]);
  free(mb_aff_ctx_copy);
  
  return skip;
}




/*!
 ************************************************************************
 * \brief
 *    This function is used to arithmetically decode the motion
 *    vector data of a B-frame MB.
 ************************************************************************
 */
void readMVD_CABAC( SyntaxElement *se,
                    struct inp_par *inp,
                    struct img_par *img,
                    DecodingEnvironmentPtr dep_dp)
{
  int i = img->subblock_x;
  int j = img->subblock_y;
  int a, b;
  int act_ctx;
  int act_sym;
  int mv_local_err;
  int mv_sign;
  int list_idx = se->value2 & 0x01;
  int k = (se->value2>>1); // MVD component

  PixelPos block_a, block_b;

  MotionInfoContexts *ctx = img->currentSlice->mot_ctx;
  Macroblock *currMB = &img->mb_data[img->current_mb_nr];

  getLuma4x4Neighbour(img->current_mb_nr, i, j, -1,  0, &block_a);
  getLuma4x4Neighbour(img->current_mb_nr, i, j,  0, -1, &block_b);

  if (block_b.available)
  {
    b = absm(img->mb_data[block_b.mb_addr].mvd[list_idx][block_b.y][block_b.x][k]);
    if (img->MbaffFrameFlag && (k==1)) 
    {
      if ((currMB->mb_field==0) && (img->mb_data[block_b.mb_addr].mb_field==1))
        b *= 2;
      else if ((currMB->mb_field==1) && (img->mb_data[block_b.mb_addr].mb_field==0))
        b /= 2;
    }
  }
  else
    b=0;
          
  if (block_a.available)
  {
    a = absm(img->mb_data[block_a.mb_addr].mvd[list_idx][block_a.y][block_a.x][k]);
    if (img->MbaffFrameFlag && (k==1)) 
    {
      if ((currMB->mb_field==0) && (img->mb_data[block_a.mb_addr].mb_field==1))
        a *= 2;
      else if ((currMB->mb_field==1) && (img->mb_data[block_a.mb_addr].mb_field==0))
        a /= 2;
    }
  }
  else
    a = 0;

  if ((mv_local_err=a+b)<3)
    act_ctx = 5*k;
  else
  {
    if (mv_local_err>32)
      act_ctx=5*k+3;
    else
      act_ctx=5*k+2;
  }
  se->context = act_ctx;

  act_sym = biari_decode_symbol(dep_dp,&ctx->mv_res_contexts[0][act_ctx] );

  if (act_sym != 0)
  {
    act_ctx=5*k;
    act_sym = unary_exp_golomb_mv_decode(dep_dp,ctx->mv_res_contexts[1]+act_ctx,3);
    act_sym++;
    mv_sign = biari_decode_symbol_eq_prob(dep_dp);

    if(mv_sign)
      act_sym = -act_sym;
  }
  se->value1 = act_sym;

#if TRACE
  fprintf(p_trace, "@%d %s\t\t\t%d \n",symbolCount++, se->tracestring, se->value1);
  fflush(p_trace);
#endif
}


/*!
 ************************************************************************
 * \brief
 *    This function is used to arithmetically decode the 8x8 block type.
 ************************************************************************
 */
void readB8_typeInfo_CABAC (SyntaxElement *se,
                            struct inp_par *inp,
                            struct img_par *img,
                            DecodingEnvironmentPtr dep_dp)
{
  int act_sym = 0;
  int bframe  = (img->type==B_SLICE);

  MotionInfoContexts *ctx = (img->currentSlice)->mot_ctx;


  if (!bframe)
  {
    if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[0][1]))
    {
      act_sym = 0;
    }
    else
    {
      if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[0][3]))
      {
        if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[0][4])) act_sym = 2;
        else                                                            act_sym = 3;
      }
      else
      {
        act_sym = 1;
      }
    }
  }
  else
  {
    if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][0]))
    {
      if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][1]))
      {
        if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][2]))
        {
          if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3]))
          {
            act_sym = 10;
            if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym++;
          }
          else
          {
            act_sym = 6;
            if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym+=2;
            if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym++;
          }
        }
        else
        {
          act_sym=2;
          if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym+=2;
          if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym+=1;
        }
      }
      else
      {
        if (biari_decode_symbol (dep_dp, &ctx->b8_type_contexts[1][3])) act_sym = 1;
        else                                                            act_sym = 0;
      }
      act_sym++;
    }
    else
    {
      act_sym= 0;
    }
  }
  se->value1 = act_sym;

#if TRACE
  fprintf(p_trace, "@%d %s\t\t%d\n",symbolCount++, se->tracestring, se->value1);
  fflush(p_trace);
#endif
}

/*!
 ************************************************************************

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一级二级三级| 国产美女精品在线| www国产成人免费观看视频 深夜成人网| 国产在线不卡一区| 亚洲午夜一二三区视频| 久久这里只有精品首页| 欧美三级资源在线| 国产成人精品影院| 久久激情综合网| 亚洲v中文字幕| 日本一区二区三区四区| 日韩欧美黄色影院| 在线日韩一区二区| 99久久精品国产网站| 久国产精品韩国三级视频| 亚洲精品中文在线| 中文字幕精品一区二区三区精品 | 91国产丝袜在线播放| 国产乱淫av一区二区三区 | 欧美一区二区国产| 欧洲另类一二三四区| 成人看片黄a免费看在线| 国产在线不卡一卡二卡三卡四卡| 亚洲图片自拍偷拍| 日韩理论片在线| 久久精品亚洲精品国产欧美kt∨| 日韩免费电影网站| 欧美精品免费视频| 欧美视频在线不卡| 91福利小视频| 91一区在线观看| 色综合久久中文字幕| 国产成人夜色高潮福利影视| 美女看a上一区| 日韩电影在线观看电影| 亚洲国产精品一区二区久久| 夜夜嗨av一区二区三区中文字幕| 亚洲视频免费在线| 日韩一区中文字幕| 亚洲欧美色图小说| 亚洲视频免费观看| 亚洲与欧洲av电影| 樱桃视频在线观看一区| 一区二区三区精品| 五月天激情小说综合| 亚瑟在线精品视频| 午夜精品久久久久久不卡8050| 国产免费久久精品| 国产精品高潮久久久久无| 日韩欧美三级在线| 精品国产91乱码一区二区三区| 91精品国产色综合久久| 欧美一区欧美二区| 欧美精品一区二区三区一线天视频| 日韩欧美专区在线| 精品91自产拍在线观看一区| 日韩欧美亚洲国产另类| 久久精品网站免费观看| 国产精品嫩草99a| 亚洲日本一区二区三区| 亚洲电影一区二区| 另类成人小视频在线| 老汉av免费一区二区三区| 视频一区二区不卡| 国产精品美女久久久久久2018| 欧美国产一区视频在线观看| 综合自拍亚洲综合图不卡区| 日韩毛片精品高清免费| 理论片日本一区| 精品一区免费av| 麻豆久久久久久| 国产一区二区剧情av在线| 成人免费三级在线| 色国产综合视频| 91高清视频在线| 欧美高清视频不卡网| 91精品国产综合久久精品性色| 欧美成人在线直播| 国产精品美女久久久久久 | 91精品国产综合久久蜜臀| 亚洲精品一线二线三线无人区| 亚洲欧美一区二区视频| 亚洲综合丁香婷婷六月香| 538在线一区二区精品国产| 欧美日韩久久久| 国产精品看片你懂得| 亚洲成在人线免费| 国产成人精品网址| 欧美日韩国产bt| 亚洲国产精品成人综合| 亚洲国产一区二区三区青草影视| 久久99精品一区二区三区三区| 成人黄色在线视频| 91精品国产色综合久久不卡电影| 亚洲欧美日韩久久| 美日韩一区二区三区| 国产成人免费在线观看不卡| 在线观看免费成人| 国产欧美精品一区二区色综合| 国产农村妇女精品| 日本欧美一区二区三区| 精品一区二区在线播放| 国产精品69毛片高清亚洲| 成人性色生活片免费看爆迷你毛片| 国产不卡在线一区| 色婷婷综合久色| 欧美成人一区二区三区 | 欧美精品18+| 久久美女艺术照精彩视频福利播放| 中文字幕日韩一区| 日韩精品亚洲专区| 懂色av一区二区夜夜嗨| 国内成+人亚洲+欧美+综合在线| 国产精品一区在线| 91久久精品一区二区二区| 欧美日韩精品系列| 一区二区三区在线播放| 日本欧美韩国一区三区| 激情综合色综合久久| 日韩女同互慰一区二区| 久久蜜桃香蕉精品一区二区三区| 欧美一区三区二区| 亚洲国产日韩精品| 国产精品不卡一区二区三区| 99精品视频在线免费观看| 国内一区二区视频| 日韩电影在线观看电影| 丝袜美腿亚洲一区二区图片| 成人听书哪个软件好| 国产日韩精品一区| 91同城在线观看| 亚洲欧洲国产日本综合| 日韩成人午夜电影| 粗大黑人巨茎大战欧美成人| 欧美成人aa大片| 亚洲伊人伊色伊影伊综合网| 黑人精品欧美一区二区蜜桃| 欧美va亚洲va香蕉在线| 日本大胆欧美人术艺术动态| 激情综合五月婷婷| 国产精品卡一卡二卡三| 欧美三级日韩三级国产三级| 激情都市一区二区| 国产精品美女www爽爽爽| 日韩精品一区二区在线观看| 成人久久久精品乱码一区二区三区 | 久久国产尿小便嘘嘘尿| 久久精品视频在线看| 国产精品免费aⅴ片在线观看| 久久色在线视频| 99久久精品99国产精品| 激情伊人五月天久久综合| 亚洲精品自拍动漫在线| 这里只有精品电影| 国产99精品国产| 亚洲国产综合色| 日韩欧美国产成人一区二区| 久久精品国产亚洲高清剧情介绍| 久久久精品综合| 色狠狠色狠狠综合| 国产成人午夜99999| 免费久久精品视频| 亚洲欧美自拍偷拍色图| 91精品国产高清一区二区三区 | 国产成人在线电影| 亚洲另类色综合网站| 欧美午夜一区二区| 97久久久精品综合88久久| 国产精品18久久久久久久久| 白白色亚洲国产精品| 国产乱妇无码大片在线观看| 国产精品二三区| 欧美国产欧美综合| 舔着乳尖日韩一区| 亚洲成人午夜影院| 蜜桃久久久久久| 日本伊人精品一区二区三区观看方式| 一区二区三区产品免费精品久久75| 久久亚洲捆绑美女| 色综合网色综合| 精品一区二区三区的国产在线播放| 777a∨成人精品桃花网| 91麻豆精品91久久久久久清纯| 国产午夜精品一区二区三区嫩草 | 国产精品理论片| 成人免费三级在线| 日韩精品视频网站| 中文一区在线播放| 欧美四级电影在线观看| 狠狠久久亚洲欧美| 国产精品免费视频一区| 欧美日韩一卡二卡三卡| 91精品在线一区二区| 日韩视频免费观看高清完整版| 欧美一区二区在线免费观看| 99在线精品视频| 日本伊人色综合网| 国模一区二区三区白浆| 国产真实精品久久二三区| 国产原创一区二区三区|