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

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

?? slice.c

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

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

#include "contributors.h"

#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/timeb.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>

#include "global.h"
#include "header.h"
#include "rtp.h"
#include "nalu.h"
#include "annexb.h"
#include "parset.h"
#include "fmo.h"
#include "vlc.h"
#include "image.h"
#include "cabac.h"
#include "elements.h"
#include "mbuffer.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];

/*!
 ************************************************************************
 * \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;
	}

  init_ref_pic_list_reordering();

  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);
      *(stat->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);
      *(stat->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;

  set_ref_pic_num();

  if (img->type == B_SLICE)
      compute_collocated(Co_located, listX);

  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
  stat->bit_slice += len;
  stat->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
        img->bot_MB = 1; //for Rate control

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品电影一区二区| 一区二区三区四区激情| 日韩av电影免费观看高清完整版 | 怡红院av一区二区三区| 久久99久久久欧美国产| 日韩欧美黄色影院| 亚洲成a人v欧美综合天堂| 欧美亚洲另类激情小说| 国产精品乱人伦| 成人午夜免费av| 亚洲天堂免费看| 成人精品视频一区| 1024成人网| 精品久久久久久亚洲综合网| 高清在线成人网| 国产精品视频你懂的| 欧美日韩国产三级| a亚洲天堂av| 26uuu国产日韩综合| 狠狠狠色丁香婷婷综合激情| 中文字幕在线不卡国产视频| 91亚洲国产成人精品一区二三| 天堂av在线一区| 日韩精品一区二区三区中文不卡| 国产精品麻豆视频| 日韩国产欧美三级| 久久久蜜臀国产一区二区| 91麻豆文化传媒在线观看| 日本视频在线一区| 亚洲线精品一区二区三区| 精品电影一区二区| 99久久综合99久久综合网站| 麻豆freexxxx性91精品| 亚洲成av人片在线| 日韩欧美一区二区不卡| 成人h精品动漫一区二区三区| 亚洲黄色免费电影| 久久看人人爽人人| 色素色在线综合| 日本韩国精品在线| 粉嫩久久99精品久久久久久夜 | 精品入口麻豆88视频| 色狠狠色狠狠综合| 精品中文字幕一区二区小辣椒| 国产欧美综合在线| 国产日韩欧美a| 在线一区二区视频| 狠狠v欧美v日韩v亚洲ⅴ| 一区二区三区四区蜜桃| 久久久精品蜜桃| 欧美另类videos死尸| 成人永久免费视频| 日韩一区二区电影在线| 日韩成人dvd| 免费成人在线影院| 激情综合色播激情啊| 成+人+亚洲+综合天堂| 日韩电影免费一区| 欧美日韩国产美| 在线不卡一区二区| 欧美一区二区三区婷婷月色| 91免费观看在线| 97久久人人超碰| 精品一区免费av| 国内久久婷婷综合| 日韩电影在线观看电影| 日本二三区不卡| 日日摸夜夜添夜夜添国产精品 | 青青草国产成人av片免费| 裸体健美xxxx欧美裸体表演| 精品午夜一区二区三区在线观看| 久久国产福利国产秒拍| 日韩影院免费视频| 精品一区二区在线观看| 成人激情电影免费在线观看| 亚洲午夜免费福利视频| 五月婷婷综合激情| 亚洲欧美日本在线| 国产精品国产三级国产有无不卡 | 另类人妖一区二区av| 亚洲国产成人在线| 国产欧美精品一区二区三区四区 | 精品久久久久久最新网址| 欧美高清视频www夜色资源网| 日韩欧美在线123| 国产精品国产三级国产aⅴ无密码| 91精品国产入口| 日韩欧美国产精品一区| 欧美日韩国产123区| 欧美日韩一级片在线观看| 久久久九九九九| 日韩欧美色综合| 久久久久高清精品| 欧美xxxxxxxx| 国产日韩欧美精品电影三级在线 | 色综合色狠狠天天综合色| 精品一区二区三区免费播放| 日本va欧美va瓶| 国产原创一区二区三区| 91在线观看下载| 日本丰满少妇一区二区三区| 色猫猫国产区一区二在线视频| 99久久国产综合精品色伊| 不卡一区中文字幕| 91麻豆产精品久久久久久| 国产女人水真多18毛片18精品视频| 中文字幕在线不卡视频| 欧美亚洲综合色| 日韩一本二本av| 国产精品美女视频| 日韩在线一区二区三区| 美国av一区二区| 丁香婷婷综合网| 在线看国产日韩| 日本一区二区三区dvd视频在线| 国产视频视频一区| 亚洲国产sm捆绑调教视频| 狠狠色综合播放一区二区| 国产一二精品视频| 色偷偷久久人人79超碰人人澡| 在线成人av网站| 久久久久久免费网| 欧美亚洲国产怡红院影院| 国产一区二区三区免费在线观看| 精品一区二区精品| 91福利精品第一导航| 久久青草欧美一区二区三区| 亚洲欧美日韩在线不卡| 欧美日韩三级在线| 色先锋资源久久综合| 午夜精品在线看| 国产精品久久久久久久第一福利| 奇米影视7777精品一区二区| 国产呦萝稀缺另类资源| 91国产免费看| 中文字幕一区二区三区色视频| 国产一区二区福利| 日韩一区二区三区观看| 国产精品美女一区二区三区| a亚洲天堂av| 久久久不卡网国产精品二区| 日韩专区在线视频| 欧美日韩高清影院| 日本不卡不码高清免费观看| 日韩一区二区免费在线电影| 久久66热re国产| 色狠狠一区二区三区香蕉| 日韩女优av电影在线观看| 亚洲精品欧美在线| 色婷婷综合久久| 亚洲bdsm女犯bdsm网站| 日韩一区二区在线看| 国产一区二区在线观看视频| 婷婷综合另类小说色区| 美女在线观看视频一区二区| 欧美性受xxxx黑人xyx性爽| 欧美视频日韩视频在线观看| 亚洲影视在线播放| 成人h版在线观看| 亚洲激情自拍视频| 欧美一区二区三区视频免费| 久久成人久久爱| 精品国产乱码久久久久久闺蜜 | 日韩精品一区二区三区在线观看| 91视频国产观看| 欧美日韩一区二区不卡| 蜜桃视频在线一区| 欧美国产禁国产网站cc| 一本一本大道香蕉久在线精品 | 91视视频在线直接观看在线看网页在线看| wwwwww.欧美系列| 日韩精品一卡二卡三卡四卡无卡| 久久久亚洲国产美女国产盗摄 | 久久青草国产手机看片福利盒子| 日韩免费视频一区二区| 捆绑变态av一区二区三区| 欧美老年两性高潮| 人人爽香蕉精品| 91精品1区2区| 亚洲天堂精品在线观看| 国产欧美精品区一区二区三区| 五月天亚洲精品| 风流少妇一区二区| 久久久高清一区二区三区| 亚洲欧洲精品一区二区三区不卡| 亚洲欧美中日韩| 欧美一区二区免费观在线| 国产成人在线免费观看| 亚洲一区二区三区四区的| 久久久久久久久久美女| 欧美视频日韩视频| youjizz久久| 另类综合日韩欧美亚洲| 一区二区三区国产| 欧美激情综合在线| 在线播放亚洲一区| 91女厕偷拍女厕偷拍高清| 成人黄色小视频在线观看| 亚洲成人av免费| 国产一区二区三区av电影|