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

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

?? cabac.c

?? H264解碼器,本解碼器實現了圖像的264解碼
?? 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一区二区三区免费野_久草精品视频
欧美在线观看视频一区二区 | 欧美日韩国产首页在线观看| 欧美性色黄大片手机版| 日韩美女在线视频| 国产女同性恋一区二区| 免费在线看一区| 欧美日本一区二区| 国产精品久线在线观看| 蜜桃久久久久久久| 欧美午夜精品免费| 一区二区在线免费观看| 国产一区三区三区| 久久久久久亚洲综合影院红桃| 天堂va蜜桃一区二区三区| 在线观看网站黄不卡| 国产精品美女一区二区三区 | 精品sm捆绑视频| 日本不卡一区二区三区| 欧美日韩午夜在线| 视频一区视频二区中文| 制服丝袜中文字幕亚洲| 免费一区二区视频| 久久先锋影音av鲁色资源| 韩国三级电影一区二区| 日韩午夜精品电影| 久久精品国产亚洲高清剧情介绍 | 欧美在线免费观看视频| 亚洲国产欧美在线| 日韩欧美不卡一区| 久久99九九99精品| 精品国产3级a| 色综合网站在线| 日本欧美在线看| 欧美国产综合一区二区| 欧美亚洲高清一区| 老司机精品视频在线| 国产精品国产馆在线真实露脸| 91老师片黄在线观看| 人人狠狠综合久久亚洲| 国产日产欧产精品推荐色| 日韩精品一区在线观看| 国模大尺度一区二区三区| 亚洲视频你懂的| 久久这里都是精品| 制服丝袜中文字幕亚洲| fc2成人免费人成在线观看播放| 欧美sm极限捆绑bd| 国产乱人伦偷精品视频不卡| 亚洲欧美日韩电影| 亚洲国产精品国自产拍av| 欧美区视频在线观看| 成人午夜视频免费看| 青青草成人在线观看| 亚洲男人的天堂一区二区| 69p69国产精品| 99久久99精品久久久久久| 三级不卡在线观看| 亚洲精品欧美在线| 亚洲国产经典视频| 欧美激情一区二区三区在线| 欧美一区二区三级| 欧美高清视频在线高清观看mv色露露十八 | 尤物av一区二区| 一区二区三区小说| 亚洲一区在线观看免费观看电影高清| 久久精品水蜜桃av综合天堂| 欧美日韩中字一区| 欧美又粗又大又爽| 欧美亚洲动漫精品| 欧美色男人天堂| 欧美麻豆精品久久久久久| 91精品久久久久久蜜臀| 99这里都是精品| 91麻豆国产在线观看| 丰满亚洲少妇av| 色噜噜狠狠色综合中国| 欧美自拍偷拍一区| 欧美日韩国产一级片| 欧美日韩亚州综合| 欧美一区二区精美| 国产亚洲一区二区三区四区| 国产精品久久国产精麻豆99网站 | 久久蜜桃香蕉精品一区二区三区| 久久久综合精品| 亚洲国产欧美日韩另类综合| 国产成人午夜视频| 欧美一区二区人人喊爽| 亚洲一区视频在线观看视频| 国产成人免费高清| 日韩三区在线观看| 亚洲第四色夜色| 92精品国产成人观看免费| 精品欧美一区二区久久| 秋霞影院一区二区| 欧美日本不卡视频| 亚洲在线观看免费视频| 成人av网站在线| 中文字幕第一区二区| 国产东北露脸精品视频| 精品美女在线播放| 麻豆国产欧美日韩综合精品二区| 欧美视频在线观看一区二区| 亚洲一区二区三区四区中文字幕| 91亚洲国产成人精品一区二三 | 亚洲精品伦理在线| 色婷婷久久久综合中文字幕 | 99久久精品免费精品国产| 欧美国产一区二区| 国产精品一区二区在线观看不卡 | av一区二区三区黑人| 1024成人网| 9人人澡人人爽人人精品| 精品国产乱码久久久久久老虎 | 久久99精品一区二区三区| 欧美日本在线观看| 久草这里只有精品视频| 国产人成一区二区三区影院| 91天堂素人约啪| 日韩精品乱码免费| 国产亚洲一区二区三区| 欧美亚洲综合色| 韩国成人福利片在线播放| 国产精品传媒视频| 在线欧美一区二区| 久久99国产精品免费网站| 亚洲欧美综合在线精品| 欧美一区午夜视频在线观看| 国产精品1024久久| 婷婷开心久久网| 中文无字幕一区二区三区| 91福利在线导航| 国产精品一区二区三区乱码 | 一区二区三区小说| 欧美精品一区二| 91精品国产综合久久蜜臀| 9人人澡人人爽人人精品| 蜜臀av一区二区三区| 亚洲一区二区三区四区在线免费观看| 日韩精品影音先锋| 欧美一区二区成人6969| 色婷婷av一区二区三区软件| 波多野结衣中文字幕一区| 久久精品国产在热久久| 人人精品人人爱| 日本在线不卡视频| 天堂av在线一区| 三级在线观看一区二区 | 久久一区二区三区四区| 9191精品国产综合久久久久久| av成人免费在线| 97久久精品人人做人人爽| 福利一区二区在线观看| av电影天堂一区二区在线观看| 国产电影一区在线| av男人天堂一区| 99国产欧美另类久久久精品| 91在线视频播放| 欧美系列在线观看| 欧美肥胖老妇做爰| 欧美大度的电影原声| 久久久久久毛片| 国产精品入口麻豆原神| 亚洲欧美一区二区三区久本道91| 亚洲人成网站影音先锋播放| 夜夜精品视频一区二区| 日本aⅴ亚洲精品中文乱码| 精久久久久久久久久久| 不卡的av网站| 日韩一区二区三区观看| 中文字幕国产精品一区二区| 亚洲国产成人av| 国产精品888| 67194成人在线观看| 中文文精品字幕一区二区| 五月激情综合网| 国产成人av福利| 欧美日韩国产经典色站一区二区三区| 欧美挠脚心视频网站| 国产欧美日韩麻豆91| 天堂久久一区二区三区| 福利电影一区二区| 日韩精品在线一区二区| 有坂深雪av一区二区精品| 国产sm精品调教视频网站| 欧美日韩国产精选| 亚洲综合在线观看视频| 国产一本一道久久香蕉| 日韩一区二区电影| 午夜在线成人av| 精品视频一区二区不卡| 综合久久综合久久| 国产精品自拍三区| 国产亚洲精久久久久久| 日韩成人av影视| 欧美一区二区三区免费视频 | 欧美激情在线一区二区| 国产福利一区二区三区| 欧美国产视频在线| 99久久伊人精品| 亚洲一区二区三区四区在线|