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

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

?? cabac.c

?? h264標準的VC實現
?? 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
}

/*!
 ************************************************************************
 * \brief
 *    This function is used to arithmetically decode the macroblock
 *    type info of a given MB.
 ************************************************************************
 */
void readMB_skip_flagInfo_CABAC( SyntaxElement *se,
                                 struct inp_par *inp,
                                 struct img_par *img,
                                 DecodingEnvironmentPtr dep_dp)
{
  int a, b;
  int act_ctx;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合天天视频在线观看 | 石原莉奈一区二区三区在线观看| 婷婷夜色潮精品综合在线| 久久99国内精品| 欧美性videosxxxxx| 国产精品视频一二| 韩国一区二区三区| 欧美日韩一区二区在线观看| 国产精品视频第一区| 久久国产精品露脸对白| 色综合中文综合网| 美日韩一区二区| 欧美日韩国产成人在线91| 中文字幕中文字幕一区| 国产综合一区二区| 欧美一区二区视频观看视频| 五月婷婷综合网| 美国十次了思思久久精品导航| 国产成人高清视频| 精品sm在线观看| 韩国中文字幕2020精品| 日韩一区二区三区免费观看| 日韩影院免费视频| 欧美精选一区二区| 日韩精品电影在线观看| 欧美片在线播放| 亚洲1区2区3区4区| 在线电影院国产精品| 日韩精品欧美成人高清一区二区| 在线视频你懂得一区二区三区| 亚洲视频狠狠干| 欧美成人激情免费网| 久久成人久久鬼色| 久久久久久一二三区| 国产综合久久久久久久久久久久| 日韩区在线观看| 狠狠色狠狠色合久久伊人| 久久久久久久综合日本| 国产成人av一区二区三区在线观看| 国产午夜亚洲精品羞羞网站| 成人午夜碰碰视频| 成人欧美一区二区三区| 色婷婷av一区| 亚洲成人免费视| 日韩欧美色综合网站| 精品一区二区三区日韩| 欧美激情综合在线| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲靠逼com| 欧美一区二区三区电影| 国内精品伊人久久久久av影院| 久久综合九色综合97_久久久| 丰满岳乱妇一区二区三区| 亚洲免费色视频| 欧美一卡二卡三卡| 国产91富婆露脸刺激对白| 亚洲美腿欧美偷拍| 日韩精品中文字幕一区| 99久久精品国产麻豆演员表| 亚洲.国产.中文慕字在线| 久久亚洲综合av| 日本高清无吗v一区| 奇米影视7777精品一区二区| 国产清纯白嫩初高生在线观看91| 色婷婷亚洲一区二区三区| 免费高清在线一区| 自拍偷拍国产精品| 日韩欧美中文字幕一区| 97久久精品人人澡人人爽| 日韩成人免费在线| 国产精品久久久久永久免费观看| 欧美日韩亚洲综合| 成人综合激情网| 男男视频亚洲欧美| 亚洲精品免费视频| 精品第一国产综合精品aⅴ| 欧美影院精品一区| 国产.欧美.日韩| 美洲天堂一区二卡三卡四卡视频| 综合分类小说区另类春色亚洲小说欧美| 91精品在线麻豆| 色婷婷亚洲一区二区三区| 色呦呦国产精品| 欧美片网站yy| 成人黄色一级视频| 美女脱光内衣内裤视频久久影院| 国产精品电影院| 久久久久9999亚洲精品| 欧美一卡二卡在线观看| 欧美日韩一区二区不卡| 99久久精品免费看国产| 国产高清亚洲一区| 麻豆高清免费国产一区| 天堂在线一区二区| 亚洲一区电影777| 亚洲美女屁股眼交3| 欧美激情一区三区| 久久久久久亚洲综合影院红桃| 欧美精品第一页| 欧日韩精品视频| 色婷婷精品久久二区二区蜜臀av | 欧美日韩激情一区| 一本一道久久a久久精品| 丁香婷婷综合网| 国产一区二区视频在线| 蜜桃av一区二区| 天堂av在线一区| 日韩在线一区二区| 午夜不卡av免费| 日韩在线播放一区二区| 肉丝袜脚交视频一区二区| 午夜影院在线观看欧美| 亚洲国产精品久久久久秋霞影院| 亚洲人快播电影网| 亚洲精品视频免费看| 一二三区精品福利视频| 亚洲一区二区不卡免费| 天天操天天干天天综合网| 同产精品九九九| 日韩精品久久理论片| 美女www一区二区| 国产一区在线观看视频| 国产成人综合亚洲网站| 成人性生交大合| aaa欧美日韩| 欧美婷婷六月丁香综合色| 欧美日韩精品欧美日韩精品| 91精品国产乱码久久蜜臀| 日韩一区二区视频在线观看| 亚洲精品在线观| 亚洲欧洲一区二区三区| 亚洲亚洲精品在线观看| 久久66热re国产| 99久久免费精品| 欧美日韩和欧美的一区二区| 日韩一本二本av| 国产精品色哟哟| 亚洲宅男天堂在线观看无病毒| 日本aⅴ精品一区二区三区 | 欧美午夜一区二区三区免费大片| 884aa四虎影成人精品一区| 久久亚洲免费视频| 1024亚洲合集| 乱一区二区av| 成人a免费在线看| 欧美精品在线观看播放| 国产亚洲综合av| 亚洲一区二区av在线| 国产精品888| 欧美日本一区二区在线观看| 欧美激情一区二区三区四区| 亚洲国产精品人人做人人爽| 国产老女人精品毛片久久| 色久优优欧美色久优优| 久久久久久久久伊人| 亚洲1区2区3区视频| 丁香六月综合激情| 欧美久久免费观看| 国产精品伦理在线| 免费久久99精品国产| 91尤物视频在线观看| 精品日韩在线一区| 亚洲永久免费av| 国产激情一区二区三区| 欧美一区二区三区在线看| 亚洲人成在线播放网站岛国| 久久99精品国产| 欧美老年两性高潮| 亚洲欧洲无码一区二区三区| 国内精品伊人久久久久av一坑| 91黄色免费网站| 自拍偷拍欧美激情| 国产激情一区二区三区四区| 日韩三级高清在线| 午夜精品视频一区| 色综合天天综合给合国产| 国产亚洲污的网站| 精品一区二区免费在线观看| 欧美日韩午夜影院| 一区二区三区在线观看视频| 国产成人精品影视| 久久婷婷一区二区三区| 久久97超碰国产精品超碰| 7777精品伊人久久久大香线蕉经典版下载| 亚洲欧美一区二区三区国产精品| 国产精品18久久久久| 日韩视频一区二区在线观看| 丝袜国产日韩另类美女| 欧美三级视频在线观看| 亚洲一区二区精品视频| 色老汉av一区二区三区| 一区二区在线观看免费视频播放| 丁香婷婷综合色啪| 国产精品久久久久久久午夜片| 国产美女在线观看一区| 久久麻豆一区二区| 国产a精品视频| 久久精品欧美一区二区三区麻豆| 国产精品一卡二| 国产精品卡一卡二卡三|