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

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

?? annexb.c

?? jm_frext22.ZIP的壓縮文件,主要用于嵌入式系統圖象的編解碼的開發.
?? C
字號:

/*!
 *************************************************************************************
 * \file annexb.c
 *
 * \brief
 *    Annex B Byte Stream format
 *
 * \author
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
 *      - Stephan Wenger                  <stewe@cs.tu-berlin.de>
 *************************************************************************************
 */

#include <stdlib.h>
#include <string.h>

#include "global.h"
#include "annexb.h"
#include "memalloc.h"


FILE *bits = NULL;                //!< the bit stream file
static int FindStartCode (unsigned char *Buf, int zeros_in_startcode);

int IsFirstByteStreamNALU=1;
int LastAccessUnitExists=0;
int NALUCount=0;


/*!
 ************************************************************************
 * \brief
 *    Returns the size of the NALU (bits between start codes in case of
 *    Annex B.  nalu->buf and nalu->len are filled.  Other field in
 *    nalu-> remain uninitialized (will be taken care of by NALUtoRBSP.
 *
 * \return
 *     0 if there is nothing any more to read (EOF)
 *    -1 in case of any error
 *
 *  \note Side-effect: Returns length of start-code in bytes. 
 *
 * \note
 *   GetAnnexbNALU expects start codes at byte aligned positions in the file
 *
 ************************************************************************
 */

int GetAnnexbNALU (NALU_t *nalu)
{
  int info2, info3, pos = 0;
  int StartCodeFound, rewind;
  char *Buf;
  int LeadingZero8BitsCount=0, TrailingZero8Bits=0;
    
  if ((Buf = (char*)calloc (nalu->max_size , sizeof(char))) == NULL) no_mem_exit("GetAnnexbNALU: Buf");

  while(!feof(bits) && (Buf[pos++]=fgetc(bits))==0);
  
  if(feof(bits))
  {
    if(pos==0)
    return 0;
    else
    {
      printf( "GetAnnexbNALU can't read start code\n");
      free(Buf);
      return -1;
    }
  }

  if(Buf[pos-1]!=1)
  {
    printf ("GetAnnexbNALU: no Start Code at the begin of the NALU, return -1\n");
    free(Buf);
    return -1;
  }

  if(pos<3)
  {
    printf ("GetAnnexbNALU: no Start Code at the begin of the NALU, return -1\n");
    free(Buf);
    return -1;
  }
  else if(pos==3)
  {
    nalu->startcodeprefix_len = 3;
    LeadingZero8BitsCount = 0;
  }
  else
  {
    LeadingZero8BitsCount = pos-4;
    nalu->startcodeprefix_len = 4;
  }

  //the 1st byte stream NAL unit can has leading_zero_8bits, but subsequent ones are not
  //allowed to contain it since these zeros(if any) are considered trailing_zero_8bits
  //of the previous byte stream NAL unit.
  if(!IsFirstByteStreamNALU && LeadingZero8BitsCount>0)
  {
    printf ("GetAnnexbNALU: The leading_zero_8bits syntax can only be present in the first byte stream NAL unit, return -1\n");
    free(Buf);
    return -1;
  }
  IsFirstByteStreamNALU=0;

  StartCodeFound = 0;
  info2 = 0;
  info3 = 0;

  while (!StartCodeFound)
  {
    if (feof (bits))
    {
      //Count the trailing_zero_8bits
      while(Buf[pos-2-TrailingZero8Bits]==0)
        TrailingZero8Bits++;
      nalu->len = (pos-1)-nalu->startcodeprefix_len-LeadingZero8BitsCount-TrailingZero8Bits;
      memcpy (nalu->buf, &Buf[LeadingZero8BitsCount+nalu->startcodeprefix_len], nalu->len);     
      nalu->forbidden_bit = (nalu->buf[0]>>7) & 1;
      nalu->nal_reference_idc = (nalu->buf[0]>>5) & 3;
      nalu->nal_unit_type = (nalu->buf[0]) & 0x1f;

// printf ("GetAnnexbNALU, eof case: pos %d nalu->len %d, nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len, nalu->nal_reference_idc, nalu->nal_unit_type);

#if TRACE
  fprintf (p_trace, "\n\nLast NALU in File\n\n");
  fprintf (p_trace, "Annex B NALU w/ %s startcode, len %d, forbidden_bit %d, nal_reference_idc %d, nal_unit_type %d\n\n",
    nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
  fflush (p_trace);
#endif
      free(Buf);
      return pos-1;
    }
    Buf[pos++] = fgetc (bits);
    info3 = FindStartCode(&Buf[pos-4], 3);
    if(info3 != 1)
      info2 = FindStartCode(&Buf[pos-3], 2);
    StartCodeFound = (info2 == 1 || info3 == 1);
  }

  //Count the trailing_zero_8bits
  if(info3==1)	//if the detected start code is 00 00 01, trailing_zero_8bits is sure not to be present
  {
    while(Buf[pos-5-TrailingZero8Bits]==0)
      TrailingZero8Bits++;
  }
  // Here, we have found another start code (and read length of startcode bytes more than we should
  // have.  Hence, go back in the file
  rewind = 0;
  if(info3 == 1)
    rewind = -4;
  else if (info2 == 1)
    rewind = -3;
  else
    printf(" Panic: Error in next start code search \n");

  if (0 != fseek (bits, rewind, SEEK_CUR))
  {
    snprintf (errortext, ET_SIZE, "GetAnnexbNALU: Cannot fseek %d in the bit stream file", rewind);
    free(Buf);
    error(errortext, 600);
  }

  // Here the leading zeros(if any), Start code, the complete NALU, trailing zeros(if any)
  // and the next start code is in the Buf.
  // The size of Buf is pos, pos+rewind are the number of bytes excluding the next
  // start code, and (pos+rewind)-startcodeprefix_len-LeadingZero8BitsCount-TrailingZero8Bits
  // is the size of the NALU.

  nalu->len = (pos+rewind)-nalu->startcodeprefix_len-LeadingZero8BitsCount-TrailingZero8Bits;
  memcpy (nalu->buf, &Buf[LeadingZero8BitsCount+nalu->startcodeprefix_len], nalu->len);
  nalu->forbidden_bit = (nalu->buf[0]>>7) & 1;
  nalu->nal_reference_idc = (nalu->buf[0]>>5) & 3;
  nalu->nal_unit_type = (nalu->buf[0]) & 0x1f;


//printf ("GetAnnexbNALU, regular case: pos %d nalu->len %d, nalu->reference_idc %d, nal_unit_type %d \n", pos, nalu->len, nalu->nal_reference_idc, nalu->nal_unit_type);
#if TRACE
  fprintf (p_trace, "\n\nAnnex B NALU w/ %s startcode, len %d, forbidden_bit %d, nal_reference_idc %d, nal_unit_type %d\n\n",
    nalu->startcodeprefix_len == 4?"long":"short", nalu->len, nalu->forbidden_bit, nalu->nal_reference_idc, nalu->nal_unit_type);
  fflush (p_trace);
#endif
  
  free(Buf);
 
  return (pos+rewind);
}




/*!
 ************************************************************************
 * \brief
 *    Opens the bit stream file named fn
 * \return
 *    none
 ************************************************************************
 */
void OpenBitstreamFile (char *fn)
{
  if (NULL == (bits=fopen(fn, "rb")))
  {
    snprintf (errortext, ET_SIZE, "Cannot open Annex B ByteStream file '%s'", input->infile);
    error(errortext,500);
  }
}


/*!
 ************************************************************************
 * \brief
 *    Closes the bit stream file
 ************************************************************************
 */
void CloseBitstreamFile()
{
  fclose (bits);
}


/*!
 ************************************************************************
 * \brief
 *    returns if new start code is found at byte aligned position buf.
 *    new-startcode is of form N 0x00 bytes, followed by a 0x01 byte.
 *
 *  \return
 *     1 if start-code is found or                      \n
 *     0, indicating that there is no start code
 *
 *  \param Buf
 *     pointer to byte-stream
 *  \param zeros_in_startcode
 *     indicates number of 0x00 bytes in start-code.
 ************************************************************************
 */
static int FindStartCode (unsigned char *Buf, int zeros_in_startcode)
{
  int info;
  int i;

  info = 1;
  for (i = 0; i < zeros_in_startcode; i++)
    if(Buf[i] != 0)
      info = 0;

  if(Buf[i] != 1)
    info = 0;
  return info;
}

void CheckZeroByteNonVCL(NALU_t *nalu, int * ret)
{
  int CheckZeroByte=0;

  //This function deals only with non-VCL NAL units
  if(nalu->nal_unit_type>=1&&nalu->nal_unit_type<=5)
    return;

  //for SPS and PPS, zero_byte shall exist
  if(nalu->nal_unit_type==NALU_TYPE_SPS || nalu->nal_unit_type==NALU_TYPE_PPS)
    CheckZeroByte=1;
  //check the possibility of the current NALU to be the start of a new access unit, according to 7.4.1.2.3
  if(nalu->nal_unit_type==NALU_TYPE_AUD  || nalu->nal_unit_type==NALU_TYPE_SPS ||
     nalu->nal_unit_type==NALU_TYPE_PPS || nalu->nal_unit_type==NALU_TYPE_SEI ||
    (nalu->nal_unit_type>=13 && nalu->nal_unit_type<=18))
  {
    if(LastAccessUnitExists)
    {
      LastAccessUnitExists=0;		//deliver the last access unit to decoder
      NALUCount=0;
    }
  }
  NALUCount++;
  //for the first NAL unit in an access unit, zero_byte shall exists
  if(NALUCount==1)
    CheckZeroByte=1;
  if(CheckZeroByte && nalu->startcodeprefix_len==3)
  {
    printf("warning: zero_byte shall exist\n");
    //because it is not a very serious problem, we may not indicate an error by setting ret to -1
    //*ret=-1;
  }
}

void CheckZeroByteVCL(NALU_t *nalu, int * ret)
{
  int CheckZeroByte=0;

  //This function deals only with VCL NAL units
  if(!(nalu->nal_unit_type>=1&&nalu->nal_unit_type<=5))
    return;

  if(LastAccessUnitExists)
  {
    NALUCount=0;
  }
  NALUCount++;
  //the first VCL NAL unit that is the first NAL unit after last VCL NAL unit indicates 
  //the start of a new access unit and hence the first NAL unit of the new access unit.						(sounds like a tongue twister :-)
  if(NALUCount==1)
    CheckZeroByte=1;
  LastAccessUnitExists=1;
  if(CheckZeroByte && nalu->startcodeprefix_len==3)
  {
	  printf("warning: zero_byte shall exist\n");
	  //because it is not a very serious problem, we may not indicate an error by setting ret to -1
	  //*ret=-1;
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产乱码久久久久久久久 | 亚洲国产一区二区三区青草影视| 成人免费福利片| 国产欧美视频一区二区| 成人在线综合网站| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 亚洲欧洲一区二区在线播放| 91浏览器打开| 五月天视频一区| 欧美大白屁股肥臀xxxxxx| 国产一区二区三区蝌蚪| 亚洲欧洲日韩在线| 欧美久久久久久久久| 麻豆国产欧美日韩综合精品二区| 2017欧美狠狠色| 99免费精品视频| 亚洲国产一区二区视频| 欧美sm极限捆绑bd| 成人av在线一区二区三区| 亚洲一区二区三区小说| 制服丝袜亚洲色图| 国产高清成人在线| 一区二区三区日韩在线观看| 日韩视频在线观看一区二区| 成人手机电影网| 午夜欧美大尺度福利影院在线看| 久久综合久久综合久久综合| 99热99精品| 蜜臀av一区二区在线观看| 国产区在线观看成人精品| 欧美在线影院一区二区| 国产尤物一区二区| 亚洲韩国一区二区三区| 久久免费国产精品| 欧美亚洲高清一区| 国产成人在线视频免费播放| 亚洲午夜三级在线| 久久先锋影音av鲁色资源网| 色av成人天堂桃色av| 精品一区二区三区在线视频| 亚洲精品国产高清久久伦理二区| 日韩欧美在线影院| 在线视频综合导航| 国产成人免费在线视频| 日韩国产欧美在线观看| 最新高清无码专区| www国产精品av| 欧美日韩一卡二卡三卡| 99久久精品国产网站| 蜜乳av一区二区| 亚洲国产欧美日韩另类综合| 国产精品卡一卡二卡三| 精品美女在线播放| 欧美日韩一二三| 99riav一区二区三区| 激情综合色综合久久| 亚洲第一成年网| 亚洲色图视频网| 国产精品嫩草影院com| 精品国产乱子伦一区| 69堂成人精品免费视频| 欧美视频在线播放| 91视频com| jiyouzz国产精品久久| 国产成人精品亚洲午夜麻豆| 久久爱另类一区二区小说| 日韩高清不卡一区二区三区| 亚洲成年人影院| 亚洲一区二区视频在线观看| 亚洲天堂av一区| 国产精品不卡在线| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 一区二区在线观看视频| 国产精品免费av| 国产精品网站一区| 欧美国产一区在线| 亚洲黄色小视频| 在线看日韩精品电影| 日本高清不卡视频| 在线免费观看视频一区| 欧美自拍偷拍午夜视频| 91免费国产在线观看| 99精品欧美一区二区三区小说| 成人爱爱电影网址| 成人av网站大全| 91免费看`日韩一区二区| 91福利在线导航| 欧美日韩视频在线第一区| 欧美日韩一级视频| 欧美一区二区三区性视频| 3d动漫精品啪啪1区2区免费| 日韩美女在线视频| 国产亚洲1区2区3区| 国产精品美女久久福利网站| 亚洲六月丁香色婷婷综合久久| 亚洲人成影院在线观看| 亚洲宅男天堂在线观看无病毒| 亚洲精品成人在线| 午夜一区二区三区视频| 欧美bbbbb| 国产做a爰片久久毛片 | 国产一区三区三区| 国产91对白在线观看九色| 99久久精品国产一区二区三区| 色94色欧美sute亚洲线路一ni | 日本在线不卡视频| 麻豆精品久久精品色综合| 高清不卡一区二区| 欧美亚洲国产一区二区三区va| 欧美一区二区三区在线观看视频| 日韩精品最新网址| 自拍偷拍亚洲欧美日韩| 日韩精品午夜视频| 国产精品一二二区| 91激情在线视频| 精品日韩成人av| 亚洲免费观看视频| 蜜桃在线一区二区三区| av中文字幕不卡| 日韩免费看的电影| 国产精品进线69影院| 日本成人超碰在线观看| 不卡一卡二卡三乱码免费网站| 91精品国产免费| 国产精品久久久久桃色tv| 午夜精品视频在线观看| 国产成a人亚洲| 91精品欧美久久久久久动漫| 国产精品乱码一区二三区小蝌蚪| 无吗不卡中文字幕| 成人黄色在线网站| 91精品国产乱码久久蜜臀| 亚洲天堂成人在线观看| 国产精品综合视频| 国产精品三级av| 男女激情视频一区| 久久人人97超碰com| 国产99久久久国产精品免费看 | 国产91露脸合集magnet| 中文字幕欧美三区| 国产精品久久毛片av大全日韩| 欧美日韩久久久一区| 国产欧美一区二区精品秋霞影院| 性做久久久久久免费观看| 国产精品一区二区三区乱码| 欧美日韩视频在线第一区 | 色狠狠色噜噜噜综合网| 欧美成人性福生活免费看| 亚洲制服丝袜一区| 色悠悠亚洲一区二区| 国产亚洲精品久| 久久国产欧美日韩精品| 91精品在线观看入口| 99精品欧美一区| 日本不卡123| 欧美日韩国产影片| 狠狠色丁香婷婷综合久久片| 国产一区二区三区久久悠悠色av| 欧美日韩精品二区第二页| 中文字幕综合网| 国产ts人妖一区二区| 欧美大度的电影原声| 日本三级韩国三级欧美三级| 欧美日韩一区二区在线观看 | 欧美人牲a欧美精品| 亚洲综合激情小说| 91亚洲精品久久久蜜桃网站| 国产精品理伦片| 不卡一区二区中文字幕| 国产精品拍天天在线| 成人高清免费观看| 日本一区二区三区高清不卡| 国产成人精品午夜视频免费| 中文天堂在线一区| 国产精品污www在线观看| 亚洲国产成人私人影院tom| 99国产精品一区| 久久丁香综合五月国产三级网站| 日韩午夜av电影| 经典三级视频一区| 午夜久久久久久久久| 日韩不卡一区二区三区| 一区二区三区在线免费视频 | 亚洲一区二区视频在线观看| 一区二区欧美视频| 亚洲成人www| 麻豆国产精品官网| 国产一区二区三区四区五区美女| 丁香亚洲综合激情啪啪综合| 色综合久久久久综合体| 欧美午夜精品久久久久久超碰 | 美日韩一区二区| 久久99蜜桃精品| 色呦呦国产精品| 在线免费视频一区二区| 欧美激情一区二区三区蜜桃视频| 最新国产精品久久精品| 婷婷综合久久一区二区三区| 国产成人综合亚洲91猫咪| 色婷婷av一区二区三区之一色屋|