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

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

?? cabac.c

?? jm_frext22.ZIP的壓縮文件,主要用于嵌入式系統圖象的編解碼的開發.
?? 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一区二区三区免费野_久草精品视频
日韩精品一区二区三区老鸭窝| 国产精品白丝在线| 国产农村妇女毛片精品久久麻豆 | 欧美又粗又大又爽| 日韩三级.com| 亚洲一二三四在线| 亚洲日本丝袜连裤袜办公室| 国产伦精品一区二区三区视频青涩 | 欧美日韩精品一区二区天天拍小说 | 亚洲婷婷综合色高清在线| 偷拍与自拍一区| www.爱久久.com| 久久久久久久久久久久久久久99 | 国产精品系列在线| 九色porny丨国产精品| 91黄色在线观看| 国产精品色婷婷久久58| 裸体一区二区三区| 欧美亚洲动漫制服丝袜| 国产精品不卡在线| 成人一区二区三区| 久久久久久**毛片大全| 美国三级日本三级久久99| 欧美视频精品在线观看| 亚洲摸摸操操av| 91视频.com| 亚洲国产成人自拍| 成人久久18免费网站麻豆| 久久婷婷成人综合色| 理论电影国产精品| 欧美α欧美αv大片| 日本美女视频一区二区| 欧美日本乱大交xxxxx| 亚洲成在线观看| 欧美精品久久一区二区三区| 五月婷婷综合激情| 欧美一区二区在线播放| 日韩精品色哟哟| 日韩三级.com| 国产精品99精品久久免费| 国产日韩精品久久久| 成人免费毛片片v| 亚洲欧洲在线观看av| 91亚洲精品久久久蜜桃| 亚洲午夜精品在线| 欧美一区二区观看视频| 国产一区二区毛片| 国产精品灌醉下药二区| 日本久久电影网| 日韩av电影免费观看高清完整版 | 麻豆国产精品官网| 精品久久人人做人人爰| 久久精品国产精品亚洲红杏| 精品日韩一区二区三区免费视频| 免费在线看一区| 精品国产一区二区三区忘忧草| 亚洲精品中文在线| 91麻豆免费看| 亚洲成在人线免费| 欧美一区二区免费视频| 激情综合色综合久久综合| 久久精品一区二区三区不卡牛牛| 国产精品18久久久久久久久| 国产日韩成人精品| av爱爱亚洲一区| 亚洲综合清纯丝袜自拍| 91丨porny丨首页| 夜夜亚洲天天久久| 91精品国产麻豆| 国产真实精品久久二三区| 日本一区二区视频在线| 91色在线porny| 日韩影院免费视频| 久久久99精品免费观看不卡| 大尺度一区二区| 亚洲一区在线观看免费观看电影高清 | 欧美猛男男办公室激情| 另类小说视频一区二区| 国产精品成人在线观看| 欧美久久久一区| 日本不卡视频在线| 国产三级久久久| 在线一区二区观看| 久久99精品久久久久久国产越南| 国产日韩精品视频一区| 欧洲亚洲国产日韩| 久久99九九99精品| 亚洲综合一区二区精品导航| 欧美成人三级在线| 91麻豆swag| 九九九精品视频| 亚洲自拍与偷拍| 欧美精品一区二区三区四区 | 天堂影院一区二区| 国产午夜一区二区三区| 欧美日韩专区在线| 热久久久久久久| 国产欧美一区二区精品婷婷| 欧美日韩精品一区二区三区蜜桃 | 午夜私人影院久久久久| 久久久久久久久岛国免费| 欧洲精品中文字幕| 国产精品一区三区| 日韩福利视频导航| 亚洲欧美色图小说| 亚洲国产精品传媒在线观看| 欧美一级日韩免费不卡| 成人福利视频在线看| 另类小说视频一区二区| 午夜精品福利在线| 最新国产の精品合集bt伙计| 久久亚洲综合色一区二区三区| 91久久精品网| 成人av集中营| 国产精品一区在线观看你懂的| 石原莉奈一区二区三区在线观看 | 中文字幕在线一区免费| 久久久久国色av免费看影院| 日韩欧美卡一卡二| 欧美肥胖老妇做爰| 欧洲中文字幕精品| 色视频欧美一区二区三区| 国产成人超碰人人澡人人澡| 国产一区激情在线| 久久99国产精品尤物| 蜜桃久久精品一区二区| 天天射综合影视| 成人欧美一区二区三区小说| 国产精品福利一区| 国产免费久久精品| 国产精品少妇自拍| 国产日韩欧美综合一区| 亚洲国产精品精华液ab| 国产精品久久久久久久久免费樱桃| 久久综合一区二区| 久久久久国色av免费看影院| 久久美女高清视频| 日韩欧美在线不卡| 欧美一区二区精品| 久久在线免费观看| 国产精品久久久久国产精品日日| 国产精品日韩成人| 亚洲欧美偷拍另类a∨色屁股| 一区二区三区色| 亚洲成国产人片在线观看| 亚洲高清在线视频| 蜜桃传媒麻豆第一区在线观看| 亚洲午夜在线电影| 天天综合网天天综合色| 激情成人综合网| 成年人国产精品| 欧美在线三级电影| 91精品国产综合久久小美女| 日韩一区二区三区视频在线| 欧美精品一区二区三区在线播放 | 国产精品精品国产色婷婷| 亚洲一二三区不卡| 美女性感视频久久| 国产成人av一区二区三区在线观看| 丁香另类激情小说| 欧美亚洲综合在线| www一区二区| 亚洲日本丝袜连裤袜办公室| 婷婷开心激情综合| 久久99热99| 成人av网站在线观看免费| 欧美亚洲综合色| 2023国产精品| 亚洲一区二区精品久久av| 老司机午夜精品99久久| 色综合中文字幕国产 | 国产精品私人影院| 午夜视频一区二区三区| 国产精品18久久久久久久久| 色婷婷激情久久| 精品国产凹凸成av人导航| 欧美韩国日本一区| 天堂蜜桃一区二区三区| 97se亚洲国产综合自在线不卡| 欧美日韩国产乱码电影| 国产欧美一区二区精品性| 日韩国产欧美视频| 99视频国产精品| 精品国产一区a| 一二三区精品福利视频| 国产精品18久久久久久久久| 欧洲生活片亚洲生活在线观看| 亚洲精品在线电影| 性欧美大战久久久久久久久| fc2成人免费人成在线观看播放 | 亚洲韩国精品一区| 成人激情黄色小说| 日韩片之四级片| 亚洲高清一区二区三区| 粉嫩高潮美女一区二区三区| 日韩欧美的一区二区| 日韩主播视频在线| 在线视频一区二区三| 中文字幕一区二区三区精华液 | 亚洲综合在线免费观看|