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

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

?? annexb.c

?? 此code含H.264解碼需要的 lib和 src
?? 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;
  unsigned char *Buf;
  int LeadingZero8BitsCount=0, TrailingZero8Bits=0;

  if ((Buf = (unsigned 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)
    {
      free (Buf);
      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一区二区三区免费野_久草精品视频
欧美午夜精品久久久久久孕妇| 国产精品69毛片高清亚洲| 欧美韩日一区二区三区| 欧美本精品男人aⅴ天堂| 欧美日本视频在线| 欧美片网站yy| 91精品婷婷国产综合久久竹菊| 欧美日韩国产一级二级| 欧美日韩免费观看一区三区| 欧美日本一区二区| 欧美一级二级三级乱码| 精品国产髙清在线看国产毛片| 欧美精品aⅴ在线视频| 日韩一区二区三| 精品国产露脸精彩对白| 欧美—级在线免费片| 亚洲女同女同女同女同女同69| 夜夜精品浪潮av一区二区三区| 亚洲国产一区视频| 久久精品国产久精国产爱| 黄一区二区三区| 99久久国产综合精品麻豆| 91社区在线播放| 在线综合视频播放| 国产蜜臀av在线一区二区三区| 国产精品超碰97尤物18| 婷婷国产在线综合| 国产99精品在线观看| 在线观看成人小视频| 日韩精品中文字幕一区二区三区 | 成人国产一区二区三区精品| 91麻豆国产香蕉久久精品| 777欧美精品| 亚洲国产高清在线| 亚洲午夜精品一区二区三区他趣| 免费成人美女在线观看.| 成人av电影在线播放| 7777精品伊人久久久大香线蕉超级流畅| 日韩精品一区国产麻豆| 亚洲嫩草精品久久| 国产一区二区三区在线看麻豆| 一本久久精品一区二区| 337p粉嫩大胆噜噜噜噜噜91av | 精品捆绑美女sm三区| 国产精品久久久久久久久动漫 | 国产一区二三区| 91网站在线观看视频| 久久这里只有精品6| 亚洲一区二区三区爽爽爽爽爽 | 中文字幕日韩欧美一区二区三区| 亚洲成人av资源| 91麻豆精东视频| 国产亚洲精品aa| 美女性感视频久久| 欧美色图第一页| 亚洲免费毛片网站| 国产精品影视在线| 91精品国产免费久久综合| 亚洲综合在线电影| 成人av网址在线| 久久久久综合网| 国内精品国产三级国产a久久| 欧美日韩久久不卡| 一区二区高清免费观看影视大全| 成人精品视频一区| 国产三级一区二区三区| 狠狠狠色丁香婷婷综合久久五月| 制服丝袜在线91| 午夜精品一区二区三区三上悠亚| 色综合av在线| 一区二区三区色| 色综合 综合色| 亚洲精品成人精品456| 色综合久久久久久久| 综合久久久久久| 色香色香欲天天天影视综合网| 国产精品久久综合| 91伊人久久大香线蕉| 亚洲人一二三区| 欧洲生活片亚洲生活在线观看| 国产精品久久久久影视| 不卡一区二区三区四区| 中文字幕五月欧美| 欧美自拍丝袜亚洲| 亚洲国产精品久久久久婷婷884 | 国产欧美日韩精品一区| 国产成人综合在线播放| 国产欧美日韩另类一区| 99精品久久免费看蜜臀剧情介绍| 综合中文字幕亚洲| 欧美午夜一区二区| 日本成人中文字幕在线视频| 日韩精品在线网站| 成人污视频在线观看| 亚洲欧美激情小说另类| 欧美色综合天天久久综合精品| 日韩成人免费电影| 国产亚洲一二三区| 色吊一区二区三区| 秋霞午夜鲁丝一区二区老狼| 精品国产一区二区精华| 成人美女在线观看| 午夜精品视频在线观看| 久久久久久久久一| 在线视频国产一区| 美女视频黄频大全不卡视频在线播放| 久久午夜羞羞影院免费观看| 91在线播放网址| 老司机免费视频一区二区三区| 亚洲国产成人在线| 欧美情侣在线播放| 不卡欧美aaaaa| 免费日本视频一区| 一区在线中文字幕| 精品88久久久久88久久久| 色又黄又爽网站www久久| 黑人巨大精品欧美黑白配亚洲 | 欧美综合在线视频| 国产精品99久| 首页欧美精品中文字幕| 国产精品理论片| 欧美va日韩va| 欧美视频一二三区| 91在线播放网址| 国产在线观看免费一区| 亚洲成人精品在线观看| 亚洲视频精选在线| 久久久久久97三级| 91精品国产综合久久久久久久| 成年人网站91| 国产精品资源网站| 全部av―极品视觉盛宴亚洲| 亚洲一区在线播放| 国产精品福利一区| 国产蜜臀97一区二区三区| 精品美女在线观看| 日韩一区二区三区免费观看| 欧美午夜精品免费| 91视频一区二区三区| 99天天综合性| 成人av资源在线| 欧美日韩免费视频| 色嗨嗨av一区二区三区| 成人av在线观| 成人免费福利片| 国产成人欧美日韩在线电影| 国产在线视频不卡二| 麻豆高清免费国产一区| 日韩vs国产vs欧美| 日韩经典一区二区| 男女视频一区二区| 卡一卡二国产精品 | 中文字幕在线不卡国产视频| 久久精品网站免费观看| 欧美va天堂va视频va在线| 精品国产凹凸成av人导航| 日韩午夜三级在线| 精品国产污污免费网站入口| 精品蜜桃在线看| 久久久av毛片精品| 欧美韩国一区二区| 日韩毛片高清在线播放| 亚洲精品一二三| 一区二区三区欧美亚洲| 首页欧美精品中文字幕| 奇米一区二区三区av| 国产又粗又猛又爽又黄91精品| 国产又粗又猛又爽又黄91精品| 韩国女主播成人在线| 成人小视频在线| 在线观看精品一区| 精品欧美一区二区久久| 日本一区二区三区四区在线视频 | eeuss鲁片一区二区三区| av电影一区二区| 欧美视频精品在线| 欧美成人综合网站| 中文字幕综合网| 日本成人中文字幕| 成人午夜看片网址| 欧美日本韩国一区| 久久综合九色综合欧美就去吻| 日本一区二区综合亚洲| 亚洲国产成人av好男人在线观看| 青青草精品视频| 成人aaaa免费全部观看| 91精品视频网| 亚洲色图清纯唯美| 九色|91porny| 91丨porny丨蝌蚪视频| 欧美一区二区日韩一区二区| 国产精品国产a级| 麻豆精品久久久| 91九色最新地址| 久久久国际精品| 丝袜美腿一区二区三区| 99久久国产免费看| 久久你懂得1024| 视频一区二区国产| 色婷婷狠狠综合|