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

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

?? slice.c

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

/*!
 **************************************************************************************
 * \file
 *    slice.c
 * \brief
 *    generate the slice header, setup the bit buffer for slices,
 *    and generates the slice NALU(s)

 * \author
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
 *      - Thomas Stockhammer            <stockhammer@ei.tum.de>
 *      - Detlev Marpe                  <marpe@hhi.de>
 *      - Stephan Wenger                <stewe@cs.tu-berlin.de>
 *      - Alexis Michael Tourapis       <alexismt@ieee.org>
 ***************************************************************************************
 */

#include "contributors.h"

#include <stdlib.h>
#include <assert.h>

#include "global.h"

#include "header.h"
#include "rtp.h"
#include "fmo.h"
#include "vlc.h"
#include "image.h"
#include "cabac.h"
#include "elements.h"

// Local declarations

static Slice *malloc_slice();
static void  free_slice(Slice *slice);
static void  init_slice(int start_mb_addr);
static void set_ref_pic_num();
extern ColocatedParams *Co_located;
extern StorablePicture **listX[6];
void poc_ref_pic_reorder(StorablePicture **list, unsigned num_ref_idx_lX_active, int *remapping_of_pic_nums_idc, int *abs_diff_pic_num_minus1, int *long_term_pic_idx, int weighted_prediction, int list_no);

/*!
 ************************************************************************
 * \brief
 *    init_ref_pic_list_reordering initializations should go here
 ************************************************************************
 */
void init_ref_pic_list_reordering()
{
  Slice* currSlice = img->currentSlice;

  currSlice->ref_pic_list_reordering_flag_l0 = 0;
  currSlice->ref_pic_list_reordering_flag_l1 = 0;
}


/*!
 ************************************************************************
 *  \brief
 *     This function generates the slice (and partition) header(s) 
 *
 *  \return number of bits used for the slice (and partition) header(s)
 *
 *  \par Side effects:
 *      Adds slice/partition header symbols to the symbol buffer
 *      increments Picture->no_slices, allocates memory for the
 *      slice, sets img->currSlice
 ************************************************************************
*/
int start_slice()
{
  EncodingEnvironmentPtr eep;
  Slice *currSlice = img->currentSlice;
  Bitstream *currStream;
  int header_len = 0;
  int i;
  int NumberOfPartitions = (input->partition_mode == PAR_DP_1?1:3);

  //one  partition for IDR img
  if(img->currentPicture->idr_flag)
  {
     NumberOfPartitions = 1;
  }

  RTPUpdateTimestamp (img->tr);   // this has no side effects, just leave it for all NALs

  for (i=0; i<NumberOfPartitions; i++)
  {
    currStream = (currSlice->partArr[i]).bitstream;

    currStream->write_flag = 0;
    if (i==0)     // First partition
      header_len += SliceHeader (0);
    else          // Second/Third partition
      header_len += Partition_BC_Header(i);
     
    //! Initialize CABAC
    if (input->symbol_mode == CABAC)
    {
      eep = &((currSlice->partArr[i]).ee_cabac);
      if (currStream->bits_to_go != 8)
        header_len+=currStream->bits_to_go;
      writeVlcByteAlign(currStream);
      arienco_start_encoding(eep, currStream->streamBuffer, &(currStream->byte_pos)/*, &(currStream->last_startcode)*/,img->type);
      cabac_new_slice();
    } else 
    {
      // Initialize CA-VLC
      CAVLC_init();
    }
  }
  if(input->symbol_mode == CABAC)
  {
    init_contexts();
  }
  return header_len;
}



/*!
 ************************************************************************
 * \brief
 *    This function terminates a slice (but doesn't write it out), 
 *    the old terminate_slice (0)
 * \return
 *    0 if OK,                                                         \n
 *    1 in case of error
 *
 ************************************************************************
 */
int terminate_slice()
{
  int bytes_written;
  Bitstream *currStream;
  Slice *currSlice = img->currentSlice;
  EncodingEnvironmentPtr eep;
  int i;
  int byte_pos_before_startcode_emu_prevention;

  if (input->symbol_mode == CABAC)
    write_terminating_bit (1);      // only once, not for all partitions
  
  for (i=0; i<currSlice->max_part_nr; i++)
  {
    currStream = (currSlice->partArr[i]).bitstream;
    if (input->symbol_mode == UVLC)
    {
      SODBtoRBSP(currStream);
      byte_pos_before_startcode_emu_prevention = currStream->byte_pos;
      currStream->byte_pos = RBSPtoEBSP(currStream->streamBuffer, 0 , currStream->byte_pos, 0);
      *(stats->em_prev_bits) += (currStream->byte_pos - byte_pos_before_startcode_emu_prevention) * 8;
    }
    else     // CABAC
    {
      eep = &((currSlice->partArr[i]).ee_cabac);
      // terminate the arithmetic code
      arienco_done_encoding(eep);
      currStream->bits_to_go = eep->Ebits_to_go;
      currStream->byte_buf = 0;
      bytes_written = currStream->byte_pos;
      byte_pos_before_startcode_emu_prevention= currStream->byte_pos;
      currStream->byte_pos = RBSPtoEBSP(currStream->streamBuffer, 0, currStream->byte_pos, eep->E);
      *(stats->em_prev_bits) += (currStream->byte_pos - byte_pos_before_startcode_emu_prevention) * 8;
    }           // CABAC
  }           // partition loop
  if( input->symbol_mode == CABAC )
  {
    store_contexts();
  }

  return 0;   
}

/*!
************************************************************************
* \brief
*    Encodes one slice
* \par
*   returns the number of coded MBs in the SLice 
************************************************************************
*/
int encode_one_slice (int SliceGroupId, Picture *pic)
{
  Boolean end_of_slice = FALSE;
  Boolean recode_macroblock;
  int len;
  int NumberOfCodedMBs = 0;
  int CurrentMbAddr;
  double FrameRDCost, FieldRDCost;
  
  img->cod_counter = 0;

  CurrentMbAddr = FmoGetFirstMacroblockInSlice (SliceGroupId);
// printf ("\n\nEncode_one_slice: PictureID %d SliceGroupId %d  SliceID %d  FirstMB %d \n", img->tr, SliceGroupId, img->current_slice_nr, CurrentMbInScanOrder);

  init_slice (CurrentMbAddr);
  Bytes_After_Header = img->currentSlice->partArr[0].bitstream->byte_pos;

  if (input->symbol_mode==CABAC)
  {
    SetCtxModelNumber ();
  }

/*
  // Tian Dong: June 7, 2002 JVT-B042
  // When the pictures are put into different layers and subseq, not all the reference frames
  // in multi-frame buffer are valid for prediction. The acutual number of the valid reference
  // frames, fb->num_short_used, will be given by start_slice(sym).
  // Save the fb->short_used.
  if (input->NumFramesInELSubSeq)
    {
      short_used = fb->short_used;
      img_ref = img->nb_references;
    }
*/

  len = start_slice ();

  // Rate control
  img->NumberofHeaderBits +=len;

  // basic unit layer rate control
  if(img->BasicUnit<img->Frame_Total_Number_MB)
    img->NumberofBasicUnitHeaderBits +=len;

//  printf("short size, used, num-used: (%d,%d,%d)\n", fb->short_size, fb->short_used, fb->num_short_used);

/*
  // Tian Dong: June 7, 2002 JVT-B042
  if (input->NumFramesInELSubSeq)
    {
      fb->short_used = fb->num_short_used;
      img->nb_references = fb->short_used + fb->long_used;
    }
*/
  // Update statistics
  stats->bit_slice += len;
  stats->bit_use_header[img->type] += len;
// printf ("\n\n");

  while (end_of_slice == FALSE) // loop over macroblocks
  {
    //sw paff
    if (!img->MbaffFrameFlag)
    {
      recode_macroblock = FALSE;
      rdopt = &rddata_top_frame_mb;   // store data in top frame MB 
      
      start_macroblock (CurrentMbAddr, FALSE);
      encode_one_macroblock ();
      write_one_macroblock (1);

      terminate_macroblock (&end_of_slice, &recode_macroblock);

// printf ("encode_one_slice: mb %d,  slice %d,   bitbuf bytepos %d EOS %d\n", 
//       img->current_mb_nr, img->current_slice_nr, 
//       img->currentSlice->partArr[0].bitstream->byte_pos, end_of_slice);

      if (recode_macroblock == FALSE)       // The final processing of the macroblock has been done
      {
        CurrentMbAddr = FmoGetNextMBNr (CurrentMbAddr);
        if (CurrentMbAddr == -1)   // end of slice
        {
// printf ("FMO End of Slice Group detected, current MBs %d, force end of slice\n", NumberOfCodedMBs+1);
          end_of_slice = TRUE;
        }
        NumberOfCodedMBs++;       // only here we are sure that the coded MB is actually included in the slice
        proceed2nextMacroblock (CurrentMbAddr);
      }
      else
      {
        //!Go back to the previous MB to recode it
        img->current_mb_nr = FmoGetPreviousMBNr(img->current_mb_nr);
        if(img->current_mb_nr == -1 )   // The first MB of the slice group  is too big,
                                        // which means it's impossible to encode picture using current slice bits restriction
        {
          snprintf (errortext, ET_SIZE, "Error encoding first MB with spcified parameter, bits of current MB may be too big");
          error (errortext, 300);
        }
      }
    }
    else                      // TBD -- Addition of FMO
    {

//! This following ugly code breaks slices, at least for a slice mode that accumulates a certain
//! number of bits into one slice.  
//! The suggested algorithm is as follows:
//!
//! SaveState (Bitstream, stats,  etc. etc.);
//! BitsForThisMBPairInFrameMode = CodeMB (Upper, FRAME_MODE) + CodeMB (Lower, FRAME_MODE);
//! DistortionForThisMBPairInFrameMode = CalculateDistortion(Upper) + CalculateDistortion (Lower);
//! RestoreState();
//! BitsForThisMBPairInFieldMode = CodeMB (Upper, FIELD_MODE) + CodeMB (Lower, FIELD_MODE);
//! DistortionForThisMBPairInFrameMode = CalculateDistortion(Upper) + CalculateDistortion (Lower);
//! FrameFieldMode = Decision (...)
//! RestoreState()
//! if (FrameFieldMode == FRAME) {
//!   CodeMB (Upper, FRAME); CodeMB (Lower, FRAME);
//! } else {
//!   CodeMB (Upper FIELD); CodeMB (Lower, FIELD);
//! }
//!
//! Open questions/issues:
//!   1. CABAC/CA-VLC state:  It seems that the CABAC/CA_VLC states are changed during the
//!      dummy encoding processes (for the R-D based selection), but that they are never
//!      reset, once the selection is made.  I believe that this breaks the MB-adaptive
//!      frame/field coding.  The necessary code for the state saves is readily available
//!      in macroblock.c, start_macroblock() and terminate_macroblock() (this code needs
//!      to be double checked that it works with CA-VLC as well
//!   2. would it be an option to allocate Bitstreams with zero data in them (or copy the
//!      already generated bitstream) for the "test coding"?  

      if (input->MbInterlace == ADAPTIVE_CODING)
      {
        //================ code MB pair as frame MB ================
        //----------------------------------------------------------
        recode_macroblock = FALSE;
        
        
        img->field_mode = 0;  // MB coded as frame
        img->top_field = 0;   // Set top field to 0
        
        //Rate control
        img->write_macroblock = 0;
        img->bot_MB = 0;   
        
        start_macroblock (CurrentMbAddr, FALSE);
        
        rdopt = &rddata_top_frame_mb; // store data in top frame MB 
        encode_one_macroblock ();     // code the MB as frame
        FrameRDCost = rdopt->min_rdcost;
        //***   Top MB coded as frame MB ***//

        //Rate control

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线欧美日韩精品| 奇米影视在线99精品| 蜜臀精品一区二区三区在线观看 | 日日噜噜夜夜狠狠视频欧美人 | 一区二区三区在线观看国产| 成人av免费在线| 国产精品嫩草久久久久| 国产成人h网站| 5566中文字幕一区二区电影| 国产精品国模大尺度视频| 国产a视频精品免费观看| 国产三区在线成人av| 国产一区二区三区四区五区入口| 精品国产伦一区二区三区免费| 美女免费视频一区| 日韩欧美一区二区在线视频| 图片区小说区区亚洲影院| 99re66热这里只有精品3直播 | 欧美一级片在线看| 日韩av一二三| 精品国产123| 丁香六月综合激情| 国产精品视频一二三区| 成人精品国产福利| 中文字幕国产一区二区| 91亚洲永久精品| 亚洲一区二区精品视频| 欧美一级二级三级乱码| 精品一区二区三区在线观看国产| 国产肉丝袜一区二区| 91欧美一区二区| 亚洲一区二区美女| 欧美在线免费观看视频| 亚洲一区免费观看| 欧美一区二区视频免费观看| 韩国欧美国产1区| 国产精品免费久久| 在线免费av一区| 美女视频黄 久久| 中文字幕一区二区三区av| 欧美日本一区二区三区| 国模套图日韩精品一区二区| 26uuu色噜噜精品一区二区| 不卡一区二区三区四区| 午夜精品久久久久久久久久久 | 日韩欧美久久久| 粉嫩嫩av羞羞动漫久久久| 亚洲一区二区三区视频在线播放| 日韩精品一区二区三区在线| av动漫一区二区| 日韩二区三区四区| 国产精品青草久久| 欧美一区二区视频网站| 91在线丨porny丨国产| 久久精品国产999大香线蕉| 国产精品乱子久久久久| 日本久久一区二区三区| 国产一区二区三区久久久| 亚洲sss视频在线视频| 亚洲激情六月丁香| 91在线精品一区二区| 精品久久久久香蕉网| 天天影视涩香欲综合网| 色婷婷国产精品| 亚洲人成小说网站色在线| 成人app下载| 亚洲天堂免费在线观看视频| 色婷婷一区二区| 日精品一区二区| 色综合久久天天| 亚洲精品一二三四区| 日韩精品一区二区三区在线 | 亚洲欧美日韩国产成人精品影院| 欧美一级免费大片| 日本韩国欧美国产| 成人一区在线观看| 日韩精品一二区| 一区二区成人在线视频| 欧美激情一区二区在线| 精品盗摄一区二区三区| 欧美日韩成人综合在线一区二区 | 91精品国产品国语在线不卡| 色狠狠一区二区三区香蕉| 高清不卡一区二区| 狠狠网亚洲精品| 蜜臀久久久久久久| 日韩综合一区二区| 天天色综合成人网| 亚洲午夜激情av| 亚洲狠狠爱一区二区三区| 综合av第一页| 亚洲图片激情小说| 成人欧美一区二区三区黑人麻豆| 精品国产乱码久久久久久浪潮 | 久久er精品视频| 另类小说一区二区三区| 日本欧美久久久久免费播放网| 视频一区视频二区在线观看| 五月天亚洲精品| 三级久久三级久久| 美女在线视频一区| 精品无码三级在线观看视频| 国产一区高清在线| 风间由美一区二区av101| 成人永久免费视频| 99久久久精品| 91福利在线看| 欧美性大战久久久久久久| 欧美精品久久99久久在免费线| 欧美三级视频在线观看| 欧美久久久久免费| 日韩欧美综合在线| 国产三级精品在线| 亚洲欧美日韩中文播放 | 欧美日韩国产一二三| 欧美在线free| 678五月天丁香亚洲综合网| 日韩欧美一级二级三级久久久| 久久一区二区三区四区| 国产精品色在线观看| 国产精品的网站| 亚洲成a人片综合在线| 久久狠狠亚洲综合| 粉嫩aⅴ一区二区三区四区五区| 欧美日韩在线观看一区二区| 国产性天天综合网| 视频一区二区不卡| 色综合色综合色综合| 精品区一区二区| 亚洲成人资源网| 国产精品一级黄| 欧美一区二区三区免费视频| 自拍偷拍亚洲激情| 国产一区二区不卡在线| 欧美日韩一区二区在线视频| 久久久久久久久久久久电影 | 中文字幕在线观看一区二区| 亚洲一区二区美女| 成人手机电影网| 欧美videofree性高清杂交| 亚洲精品伦理在线| 老司机精品视频导航| 91国模大尺度私拍在线视频| 国产精品视频看| 狠狠色丁香婷婷综合久久片| 欧美肥胖老妇做爰| 精品国产精品网麻豆系列| 99v久久综合狠狠综合久久| 精品99久久久久久| 欧美激情综合网| 国产女同性恋一区二区| 91成人国产精品| 美女www一区二区| 91成人免费在线视频| 中文字幕精品在线不卡| 国产一区二区三区免费在线观看| 欧美一区二区三区在线| 首页国产欧美久久| 欧美精品日韩一区| 亚洲国产成人精品视频| 欧美亚洲综合在线| 亚洲主播在线播放| 欧美色图一区二区三区| 亚洲综合色噜噜狠狠| 91黄色免费网站| 亚洲大尺度视频在线观看| 色哟哟一区二区| 一区二区三区四区亚洲| 在线免费观看视频一区| 亚洲综合另类小说| 欧美日韩国产一级片| 日本中文字幕一区二区视频| 欧美老女人第四色| 免费亚洲电影在线| 欧美精品一区二区三区一线天视频 | 美女一区二区视频| 欧美成人猛片aaaaaaa| 久久电影网站中文字幕| 国产亚洲一区二区三区四区| 国产福利一区二区三区视频在线| 国产日韩欧美精品电影三级在线| 成人性生交大片免费看在线播放 | 精品人伦一区二区色婷婷| 激情文学综合丁香| 国产精品嫩草影院com| 一本一道久久a久久精品| 五月天婷婷综合| 久久久国际精品| 99久久久精品| 日韩精品一二三区| 久久嫩草精品久久久久| aaa欧美大片| 丝瓜av网站精品一区二区 | 9l国产精品久久久久麻豆| 亚洲久草在线视频| 这里只有精品99re| 成人高清免费在线播放| 亚洲成人午夜电影| 久久精品视频在线看| 日本韩国一区二区三区视频|