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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cabac.c

?? h264標準的VC實現(xiàn)
?? 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 <assert.h>

#include "global.h"

#include "cabac.h"
#include "image.h"
#include "mb_access.h"

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
 ***********************************************************************
 */


void unary_bin_encode(EncodingEnvironmentPtr eep_frame,
                      unsigned int symbol,
                      BiContextTypePtr ctx,
                      int ctx_offset);

void unary_bin_max_encode(EncodingEnvironmentPtr eep_frame,
                          unsigned int symbol,
                          BiContextTypePtr ctx,
                          int ctx_offset,
                          unsigned int max_symbol);

void unary_exp_golomb_level_encode( EncodingEnvironmentPtr eep_dp,
                                   unsigned int symbol,
                                   BiContextTypePtr ctx);

void unary_exp_golomb_mv_encode(EncodingEnvironmentPtr eep_dp,
                                unsigned int symbol,
                                BiContextTypePtr ctx,
                                unsigned int max_bin);


void cabac_new_slice()
{
  last_dquant=0;
}


/*!
 ************************************************************************
 * \brief
 *    Check for available neighbouring blocks
 *    and set pointers in current macroblock
 ************************************************************************
 */
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;
}

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

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

  return enco_ctx;
}


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

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

  return enco_ctx;
}




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

  free( enco_ctx );

  return;
}

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

  free( enco_ctx );

  return;
}


/*!
 **************************************************************************
 * \brief
 *    generates arithmetic code and passes the code to the buffer
 **************************************************************************
 */
int writeSyntaxElement_CABAC(SyntaxElement *se, DataPartition *this_dataPart)
{
  int curr_len;
  EncodingEnvironmentPtr eep_dp = &(this_dataPart->ee_cabac);

  curr_len = arienco_bits_written(eep_dp);

  // perform the actual coding by calling the appropriate method
  se->writing(se, eep_dp);

  if(se->type != SE_HEADER)
    this_dataPart->bitstream->write_flag = 1;

  return (se->len = (arienco_bits_written(eep_dp) - curr_len));
}

/*!
 ***************************************************************************
 * \brief
 *    This function is used to arithmetically encode the field
 *    mode info of a given MB  in the case of mb-based frame/field decision
 ***************************************************************************
 */
void writeFieldModeInfo_CABAC(SyntaxElement *se, EncodingEnvironmentPtr eep_dp)
{
  int a,b,act_ctx;
  MotionInfoContexts *ctx         = (img->currentSlice)->mot_ctx;
  Macroblock         *currMB      = &img->mb_data[img->current_mb_nr];
  int                mb_field = se->value1;
  
  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;

  if (mb_field==0) // frame
    biari_encode_symbol(eep_dp, 0,&ctx->mb_aff_contexts[act_ctx]);
  else
    biari_encode_symbol(eep_dp, 1,&ctx->mb_aff_contexts[act_ctx]);
  
  se->context = act_ctx;
  
  return;
}

/*!
***************************************************************************
* \brief
*    This function is used to arithmetically encode the mb_skip_flag.
***************************************************************************
*/
void writeMB_skip_flagInfo_CABAC(SyntaxElement *se, EncodingEnvironmentPtr eep_dp)
{
  int a,b,act_ctx;
  int bframe   = (img->type==B_SLICE);
  MotionInfoContexts *ctx         = (img->currentSlice)->mot_ctx;
  Macroblock         *currMB      = &img->mb_data[img->current_mb_nr];
  int                curr_mb_type = se->value1;
  
  if (bframe)
  {
    if (currMB->mb_available_up == NULL)
      b = 0;
    else
      b = (currMB->mb_available_up->skip_flag==0 ? 0 : 1);
    if (currMB->mb_available_left == NULL)
      a = 0;
    else
      a = (currMB->mb_available_left->skip_flag==0 ? 0 : 1);
    
    act_ctx = 7 + a + b;

    if (se->value1==0 && se->value2==0) // DIRECT mode, no coefficients
      biari_encode_symbol (eep_dp, 1, &ctx->mb_type_contexts[2][act_ctx]);
    else
      biari_encode_symbol (eep_dp, 0, &ctx->mb_type_contexts[2][act_ctx]);   

    currMB->skip_flag = (se->value1==0 && se->value2==0)?0:1;
  }
  else
  {
    if (currMB->mb_available_up == NULL)
      b = 0;
    else
      b = (( (currMB->mb_available_up)->skip_flag != 0) ? 1 : 0 );
    if (currMB->mb_available_left == NULL)
      a = 0;
    else
      a = (( (currMB->mb_available_left)->skip_flag != 0) ? 1 : 0 );

    act_ctx = a + b;

    if (curr_mb_type==0) // SKIP
      biari_encode_symbol(eep_dp, 1,&ctx->mb_type_contexts[1][act_ctx]);
    else
      biari_encode_symbol(eep_dp, 0,&ctx->mb_type_contexts[1][act_ctx]);

    currMB->skip_flag = (curr_mb_type==0)?0:1;
  }
  se->context = act_ctx;

  return;
}

/*!
***************************************************************************
* \brief
*    This function is used to arithmetically encode the macroblock
*    intra_pred_size flag info of a given MB.
***************************************************************************
*/

void writeMB_transform_size_CABAC(SyntaxElement *se, EncodingEnvironmentPtr eep_dp)
{
  int a, b;
  int act_ctx = 0;
  int act_sym;
  
  MotionInfoContexts *ctx         = (img->currentSlice)->mot_ctx;
  Macroblock         *currMB      = &img->mb_data[img->current_mb_nr];
  
  
  if (currMB->mb_available_up == NULL)
    b = 0;
  else 
    b = currMB->mb_available_up->luma_transform_size_8x8_flag;
  
  if (currMB->mb_available_left == NULL)
    a = 0;
  else 
    a = currMB->mb_available_left->luma_transform_size_8x8_flag;
    
  act_ctx     = a + b;
  act_sym     = currMB->luma_transform_size_8x8_flag;
  se->context = act_ctx; // store context
  if(act_sym == 0)          // 4x4
    biari_encode_symbol(eep_dp, 0, ctx->transform_size_contexts + act_ctx );
  else                      // 8x8
    biari_encode_symbol(eep_dp, 1, ctx->transform_size_contexts + act_ctx );
  
}

/*!
 ***************************************************************************
 * \brief
 *    This function is used to arithmetically encode the macroblock
 *    type info of a given MB.
 ***************************************************************************
 */

void writeMB_typeInfo_CABAC(SyntaxElement *se, EncodingEnvironmentPtr eep_dp)
{
  int a, b;
  int act_ctx = 0;
  int act_sym;
  int csym;
  int bframe   = (img->type==B_SLICE);
  int mode_sym = 0;
  int mode16x16;


  MotionInfoContexts *ctx         = (img->currentSlice)->mot_ctx;
  Macroblock         *currMB      = &img->mb_data[img->current_mb_nr];
  int                curr_mb_type = se->value1;

  if(img->type == I_SLICE)  // INTRA-frame
  {
    if (currMB->mb_available_up == NULL)
      b = 0;
    else 
      b = ((currMB->mb_available_up->mb_type != I4MB &&  currMB->mb_available_up->mb_type != I8MB) ? 1 : 0 );

    if (currMB->mb_available_left == NULL)
      a = 0;
    else 
      a = ((currMB->mb_available_left->mb_type != I4MB &&  currMB->mb_available_left->mb_type != I8MB) ? 1 : 0 );
    
    act_ctx     = a + b;
    act_sym     = curr_mb_type;
    se->context = act_ctx; // store context

    if (act_sym==0) // 4x4 Intra
    {
      biari_encode_symbol(eep_dp, 0, ctx->mb_type_contexts[0] + act_ctx );
    }
    else if( act_sym == 25 ) // PCM-MODE
    {
      biari_encode_symbol(eep_dp, 1, ctx->mb_type_contexts[0] + act_ctx );

      biari_encode_symbol_final(eep_dp, 1);
    }
    else // 16x16 Intra
    {
      biari_encode_symbol(eep_dp, 1, ctx->mb_type_contexts[0] + act_ctx );

      biari_encode_symbol_final(eep_dp, 0);

      mode_sym = act_sym-1; // Values in the range of 0...23
      act_ctx  = 4;
      act_sym  = mode_sym/12;
      biari_encode_symbol(eep_dp, (unsigned char) act_sym, ctx->mb_type_contexts[0] + act_ctx ); // coding of AC/no AC
      mode_sym = mode_sym % 12;
      act_sym  = mode_sym / 4; // coding of cbp: 0,1,2
      act_ctx  = 5;
      if (act_sym==0)
      {
        biari_encode_symbol(eep_dp, 0, ctx->mb_type_contexts[0] + act_ctx );
      }
      else
      {
        biari_encode_symbol(eep_dp, 1, ctx->mb_type_contexts[0] + act_ctx );
        act_ctx=6;
        if (act_sym==1)
        {
          biari_encode_symbol(eep_dp, 0, ctx->mb_type_contexts[0] + act_ctx );

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷综合中文久久一本| 中文字幕在线免费不卡| 蜜臀久久99精品久久久久宅男| 日本vs亚洲vs韩国一区三区二区| 麻豆国产精品一区二区三区 | 91电影在线观看| 欧美精品一级二级| 日韩欧美色综合网站| 国产精品拍天天在线| 亚洲综合久久久久| 极品少妇一区二区| 99re这里只有精品首页| 7777精品久久久大香线蕉| 国产视频一区在线播放| 亚洲制服丝袜av| 国产精品一区一区| 欧美日韩一区成人| 久久久九九九九| 五月天亚洲婷婷| 处破女av一区二区| 欧美精三区欧美精三区| 国产精品日日摸夜夜摸av| 天堂在线一区二区| 成人动漫一区二区在线| 欧美高清激情brazzers| 国产精品萝li| 蜜桃免费网站一区二区三区| 色综合中文字幕| 久久免费视频色| 午夜久久久影院| voyeur盗摄精品| 欧美va亚洲va国产综合| 一区二区国产盗摄色噜噜| 精品一区二区影视| 欧美日韩一区成人| 亚洲人123区| 国产精品99久久久久久久女警| 精品视频在线视频| 中文字幕一区二区三区精华液 | 欧美tickling挠脚心丨vk| 一区二区三区免费在线观看| 国产高清不卡一区| 日韩欧美国产1| 午夜精品久久久| 91成人免费电影| 国产精品不卡在线| 国产成人免费视频网站| 欧美一区二区播放| 性做久久久久久久免费看| 99久久精品费精品国产一区二区| 久久久精品国产99久久精品芒果| 蜜臂av日日欢夜夜爽一区| 欧美色综合天天久久综合精品| 中文字幕中文字幕在线一区 | 久久久久久99久久久精品网站| 日韩精品一级中文字幕精品视频免费观看| 色综合色综合色综合 | 91久久精品一区二区三| 中文字幕电影一区| 国产精品18久久久久久久网站| 日韩免费观看高清完整版在线观看| 亚洲综合一区二区三区| 91免费视频网| 亚洲人吸女人奶水| 91亚洲永久精品| 亚洲欧洲三级电影| a亚洲天堂av| 国产精品久久二区二区| 高清beeg欧美| 欧美经典一区二区三区| 国产成人h网站| 国产精品乱子久久久久| 岛国一区二区三区| 国产精品国产三级国产普通话蜜臀 | 国产成人精品亚洲日本在线桃色 | 国产精品69久久久久水密桃| 欧美精品一区二区蜜臀亚洲| 看国产成人h片视频| 日韩精品中文字幕一区| 久久精品国产**网站演员| 日韩欧美国产一区在线观看| 久久99在线观看| 精品国产第一区二区三区观看体验| 麻豆精品一区二区综合av| 精品女同一区二区| 久久99精品久久久久久国产越南| 欧美tickling挠脚心丨vk| 国产一区二区免费在线| 国产日韩三级在线| 波多野结衣精品在线| 亚洲免费av网站| 欧美剧在线免费观看网站 | 久久亚洲二区三区| 国产成人午夜精品影院观看视频| 1000部国产精品成人观看| 91天堂素人约啪| 亚洲一二三区在线观看| 538prom精品视频线放| 久久精品国产**网站演员| 国产日韩欧美在线一区| 91免费国产在线| 亚洲成人第一页| 日韩视频在线永久播放| 国产一区在线观看麻豆| 中文字幕在线不卡一区二区三区| 欧美影视一区二区三区| 久久国产夜色精品鲁鲁99| 国产精品素人一区二区| 精品污污网站免费看| 激情综合色综合久久| 国产精品黄色在线观看| 在线成人免费观看| 国产老妇另类xxxxx| 亚洲美女一区二区三区| 日韩一区二区三区精品视频| 国产成人精品免费网站| 亚洲成人一区在线| 国产日产欧产精品推荐色| 欧美日韩在线精品一区二区三区激情| 久久精品国产久精国产爱| 国产精品久久久久久久久免费桃花 | 亚洲一区二区欧美| 日韩欧美精品在线| 91丝袜美腿高跟国产极品老师| 亚洲不卡在线观看| 精品国产sm最大网站免费看| 成人综合在线观看| 亚洲福利视频一区| 日韩视频中午一区| 成人自拍视频在线| 亚洲bt欧美bt精品| 欧美精品一区二区三区一线天视频| av在线不卡电影| 美女脱光内衣内裤视频久久影院| 国产网红主播福利一区二区| 色哟哟一区二区| 久久精品国产第一区二区三区| 中文字幕巨乱亚洲| 欧美日韩国产大片| 国产凹凸在线观看一区二区| 亚洲一区在线视频观看| 欧美一区二区三区视频在线观看| 福利一区二区在线观看| 亚洲电影在线免费观看| 久久人人超碰精品| 欧美视频一区二区| 91在线观看视频| 久久狠狠亚洲综合| 一区二区三区不卡在线观看| wwwwww.欧美系列| 在线观看三级视频欧美| 成人黄页在线观看| 人人爽香蕉精品| 亚洲精品成人天堂一二三| 欧美不卡一区二区三区四区| 国产精品中文有码| 美女视频一区二区| 一区二区三区免费看视频| 久久九九久久九九| 91精品视频网| 色综合久久88色综合天天6 | 粉嫩绯色av一区二区在线观看| 性感美女极品91精品| 国产精品久久久久久户外露出| 欧美一区二区三区在线看| 欧美日韩激情一区| 91在线观看下载| 国产老妇另类xxxxx| 天堂久久久久va久久久久| 国产精品美女久久久久久久久| 国产亚洲精品bt天堂精选| 日韩限制级电影在线观看| 欧美午夜精品理论片a级按摩| www.日韩大片| 国产一区高清在线| 毛片不卡一区二区| 午夜久久久久久久久久一区二区| 亚洲黄色性网站| 国产日本亚洲高清| 久久精品视频网| 欧美精品一区二区三区蜜桃| 91麻豆精品国产| 欧美日韩国产综合久久| 在线观看不卡一区| 91在线观看一区二区| 暴力调教一区二区三区| 高潮精品一区videoshd| 国产精品一卡二卡| 菠萝蜜视频在线观看一区| 国产丶欧美丶日本不卡视频| 国产在线精品一区二区 | 欧美日韩日本视频| 欧美精品视频www在线观看| 在线日韩一区二区| 91麻豆.com| 在线精品观看国产| 777欧美精品| 日韩欧美成人一区| 欧美mv日韩mv| 日韩欧美在线网站|