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

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

?? slice.c

?? h264標(biāo)準(zhǔn)的VC實(shí)現(xiàn)
?? C
?? 第 1 頁 / 共 3 頁
字號(hào):

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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
九九精品视频在线看| 亚洲人成精品久久久久久| 偷拍日韩校园综合在线| 91在线视频免费91| 欧美激情在线一区二区| 国产精品影视在线观看| 精品久久99ma| 久久国产麻豆精品| 精品国产凹凸成av人导航| 美女网站视频久久| 日韩精品综合一本久道在线视频| 日韩av中文字幕一区二区| 欧美精品乱码久久久久久按摩 | 欧美日韩国产综合久久| 亚洲免费观看高清| 在线免费精品视频| 亚洲电影欧美电影有声小说| 欧美日韩国产高清一区二区三区 | 经典一区二区三区| 精品国产乱码久久久久久牛牛 | 日韩精品成人一区二区三区| 欧美三级电影在线看| 亚洲国产一区二区在线播放| 欧美日韩一区二区三区免费看 | 国产精品狼人久久影院观看方式| 成人性生交大合| 中文字幕在线观看一区| 色综合久久久网| 亚洲综合无码一区二区| 欧美亚洲国产一区在线观看网站| 亚洲成在人线在线播放| 91麻豆精品国产91久久久久 | 国产真实乱对白精彩久久| 久久免费国产精品| 成人丝袜高跟foot| 亚洲欧美激情在线| 欧美日本免费一区二区三区| 免费成人av资源网| 国产日韩一级二级三级| 99re免费视频精品全部| 亚洲国产精品影院| 日韩精品一区二区三区视频在线观看| 狠狠狠色丁香婷婷综合久久五月| 国产欧美一区二区在线观看| 91免费在线看| 日韩va亚洲va欧美va久久| 欧美tickling网站挠脚心| 成人永久免费视频| 亚洲一区二区三区小说| 日韩亚洲欧美在线| 豆国产96在线|亚洲| 亚洲精品ww久久久久久p站| 欧美高清视频一二三区| 国产伦精一区二区三区| 亚洲丝袜制服诱惑| 欧美一区二区免费| 成人激情电影免费在线观看| 亚洲一二三区视频在线观看| 欧美videofree性高清杂交| av在线不卡网| 丝袜亚洲精品中文字幕一区| 国产午夜精品一区二区三区嫩草 | 免费高清在线一区| 中文av一区二区| 欧美日韩免费观看一区二区三区 | 2020国产成人综合网| 91啪九色porn原创视频在线观看| 日韩av中文字幕一区二区| 中文字幕不卡在线观看| 欧美日本免费一区二区三区| 成人午夜激情视频| 日韩激情一二三区| 国产精品激情偷乱一区二区∴| 欧美人xxxx| 国产99久久久国产精品| 日韩中文字幕1| 国产精品久久久久天堂| 欧美一区二区三区免费在线看| 成人av电影在线| 免费视频一区二区| 尤物av一区二区| 久久久精品综合| 在线电影院国产精品| 国产成人免费在线观看不卡| 婷婷综合五月天| 亚洲人成在线观看一区二区| 精品动漫一区二区三区在线观看| 欧美在线看片a免费观看| 国产成人av电影在线观看| 日韩av一二三| 亚洲九九爱视频| 国产三级精品在线| 日韩午夜在线观看视频| 欧美在线观看18| av一区二区不卡| 国产乱码精品一品二品| 日韩av一区二区在线影视| 亚洲最色的网站| 国产精品女上位| 久久亚洲一级片| 日韩欧美综合在线| 欧美午夜在线一二页| www.在线成人| 国产iv一区二区三区| 久久99精品一区二区三区| 亚洲高清免费观看 | 亚洲国产精品久久人人爱| 中文字幕制服丝袜一区二区三区 | 久久久精品国产99久久精品芒果 | 久久久国产精华| 91麻豆精品国产自产在线| 欧美中文字幕一二三区视频| 99久久精品免费观看| 丰满少妇久久久久久久| 国产呦萝稀缺另类资源| 美腿丝袜在线亚洲一区| 五月天一区二区| 亚洲午夜影视影院在线观看| 亚洲精品高清视频在线观看| 亚洲情趣在线观看| 亚洲欧洲精品天堂一级| 国产精品久久久久久久久久久免费看 | 精品日本一线二线三线不卡| 欧美性色黄大片手机版| 一本色道亚洲精品aⅴ| 99久久久久久99| 成人免费毛片app| 丁香六月久久综合狠狠色| 国产成人免费在线观看| 国产成人亚洲综合a∨婷婷| 国产精品18久久久久久久久久久久 | 欧美一区二区日韩一区二区| 欧美一区二区网站| 91精品国产高清一区二区三区蜜臀 | 色哦色哦哦色天天综合| 91日韩精品一区| 一本在线高清不卡dvd| 色悠悠久久综合| 欧美在线视频全部完| 欧美日韩精品综合在线| 欧美精品久久久久久久多人混战| 欧美久久久久久久久中文字幕| 欧美酷刑日本凌虐凌虐| 91精品国产综合久久久蜜臀图片| 欧美一区二区日韩| 精品国产乱码91久久久久久网站| 2020日本不卡一区二区视频| 国产免费观看久久| 一区在线观看免费| 一区二区三区四区视频精品免费 | 国产精品第一页第二页第三页| 国产欧美日韩三区| 国产精品的网站| 一区二区三区中文在线| 亚洲福利国产精品| 日本一道高清亚洲日美韩| 久久爱www久久做| 大白屁股一区二区视频| 成人av电影在线| 欧美日免费三级在线| 91精品在线麻豆| 久久噜噜亚洲综合| 国产精品麻豆视频| 亚洲综合视频在线| 免费成人在线网站| 精品国产乱码久久久久久免费| 欧美极品美女视频| 亚洲综合图片区| 理论电影国产精品| 丁香五精品蜜臀久久久久99网站| 色综合久久综合网97色综合 | 日韩视频在线永久播放| 久久久久久久久久看片| 亚洲欧洲三级电影| 日本免费新一区视频| 精品日本一线二线三线不卡| 国产亚洲欧美日韩在线一区| 亚洲私人黄色宅男| 蜜桃av噜噜一区二区三区小说| 粉嫩高潮美女一区二区三区| 色噜噜狠狠色综合欧洲selulu| 91精品国产91综合久久蜜臀| 久久精品视频在线免费观看| 亚洲黄色小说网站| 久久国产精品一区二区| 色综合久久综合网欧美综合网| 欧美一级片在线观看| 中文欧美字幕免费| 三级在线观看一区二区| 国产aⅴ精品一区二区三区色成熟| 日本福利一区二区| 欧美精品一区在线观看| 亚洲精品午夜久久久| 久久国内精品自在自线400部| 91色在线porny| 色94色欧美sute亚洲线路一久| 欧美www视频| 亚洲另类春色校园小说| 国产最新精品精品你懂的| 在线免费一区三区|