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

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

?? rtp.c

?? TML的參考源代碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*
***********************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2001, International Telecommunications Union, Geneva
*
* DISCLAIMER OF WARRANTY
*
* These software programs are available to the user without any
* license fee or royalty on an "as is" basis. The ITU disclaims
* any and all warranties, whether express, implied, or
* statutory, including any implied warranties of merchantability
* or of fitness for a particular purpose.  In no event shall the
* contributor or the ITU be liable for any incidental, punitive, or
* consequential damages of any kind whatsoever arising from the
* use of these programs.
*
* This disclaimer of warranty extends to the user of these programs
* and user's customers, employees, agents, transferees, successors,
* and assigns.
*
* The ITU does not represent or warrant that the programs furnished
* hereunder are free of infringement of any third-party patents.
* Commercial implementations of ITU-T Recommendations, including
* shareware, may be subject to royalty fees to patent holders.
* Information regarding the ITU-T patent policy is available from
* the ITU Web site at http://www.itu.int.
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE ITU-T PATENT POLICY.
************************************************************************
*/

/*!
 ************************************************************************
 * \file  rtp.c
 *
 * \brief
 *    Network Adaptation layer for RTP packets
 *
 * \author
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
 *    - Stephan Wenger   <stewe@cs.tu-berlin.de>
 ************************************************************************
 */


/*!

  A quick guide to the basics of the RTP decoder implementation

  This module contains the RTP packetization, de-packetization, and the
  handling of Parameter Sets, see VCEG-N52 and accompanying documents.
  Note: Compound packets are not yet implemented!

  The interface between every NAL (including the RTP NAL) and the VCL is
  based on Slices.  The slice data structure on which the VCL is working
  is defined in the type Slice (in defines.h).  This type contains the
  various fields of the slice header and a partition array, which itself
  contains the data partitions the slice consists of.  When data
  partitioning is not used, then the whole slice bit string is stored
  in partition #0.  When individual partitions are missing, this is
  indicated by the size of the bit strings in the partition array.
  A complete missing slice (e.g. if a Full Slice packet was lost) is
  indicated in a similar way.  
  
  part of the slice structure is the error indication (ei-flag).  The
  Ei-flag is set in such cases in which at least one partition of a slice
  is damaged or missing.When data partitioning is used, it can happen that
  one partition does not contain any symbols but the ei_flag is cleared,
  which indicates the intentional missing of symbols of that partition.
  A typical example for this behaviour is the Intra Slice, which does not
  have symnbols in its type C partition.

  The VCL requests new data to work on through the call of readSliceRTP().
  This function calls the main state machine of this module in ReadRTPpaacket().

  ReadRTPpacket assumes, when called, that in an error free environment
  a complete slice, consisting of one Full Slice RTP packet, or three Partition
  packets of types A, B, C with consecutive sequence numbers, can be read.
  It first interprets any trailing SUPP and Parameter Update (Header) packets.
  Then it reads one video data packet.  Two cases have to be distinguished:

  1. Type A, or Full Slice packet
  In this case, the PictureID and the macroblock mumbers are used to
  identify the potential loss of a slice.  A slice is lost, when the
  StartMB of the newly read slice header is not equal to the current
  state of the decoder
    1.1 Loss detected
      In this case the last packet is unread (fseek back), and a dummy slice
      containing the missing macroblocks is conveyed to the VCL.  At the next 
      call of the NAL, the same packet is read again, but this time no packet 
      loss is detected by the above algorithm,
    1.2. No loss
      In this case it is checked whether a Full Slice packet or a type A data
      partition was read
        1.2.1 Full Slice
          The Full Slice packet is conveyed to the NAL
        1.2.2 Type A Partition
          The function RTPReadDataPartitionedSlice() is called, which collects
          the remaining type B, C partitions and handles them appropriately.

  Paraneter Update Packets (aka Header packets) are in an SDP-like syntax
  and are interpreted by a simple parser in the function 
  RTPInterpretParameterSetPacket() 

  Each Slice header contaions the information on which parameter set to be used.
  The function RTPSetImgInp() copies the information of the relevant parameter
  set in the VCL's global variables img-> and inp->  IMPORTANT: any changes
  in the semantics of the img-> and inp-> structure members must be represented
  in this function as well!

  A note to the stream-buffer data structure: The stream buffer always contains
  only the contents of the partition in question, and not the slice/partition
  header.  Decoding has to start at bitoffset 0 (UVLC) or bytreoffset 0 (CABAC).

  The remaining functions should be self-explanatory.
  
*/

#include "contributors.h"

#include <assert.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

#include "global.h"
#include "elements.h"
#include "bitsbuf.h"
#include "rtp.h"

extern void tracebits(const char *trace_str,  int len,  int info,int value1,
    int value2) ;

extern FILE *bits;
#define MAX_PARAMETER_STRINGLEN 1000

static int CurrentParameterSet = -1;

typedef struct
{
  int FramesToBeEncoded;
  int FrameSkip;
  char SequenceFileName[MAX_PARAMETER_STRINGLEN];
  int NumberBFrames;
} InfoSet_t;

static InfoSet_t InfoSet;

ParameterSet_t ParSet[RTP_MAX_PARAMETER_SET];

//! The following two variables are used to calculate the size of a lost slice.
//! The NAL conveyes this "lost" slice to the VCL with the ei_flag set in order
//! to trigger concealment

static int LastPicID;       //! PicID of the last packet (current state of the decoder 
                            //! before reading the next packet      
static int ExpectedMBNr;    //! MB Nr of the last decoded MB


/*!
 ************************************************************************
 * \brief
 *    read all Partitions of one Slice from RTP packets
 * \return
 *    SOS if this is not a new frame                                    \n
 *    SOP if this is a new frame                                        \n
 *    EOS if end of sequence reached
 ************************************************************************
 */
int readSliceRTP (struct img_par *img, struct inp_par *inp)
{
  Slice *currSlice = img->currentSlice;
  int PartitionMask;

  assert (currSlice != NULL);

  PartitionMask = ReadRTPPacket (img, inp, bits);
/*
{
int i;
for (i=0; i<25; i++)
printf ("%02x ", currSlice->partArr[0].bitstream->streamBuffer[i]);
printf ("\n");
for (i=0; i<25; i++)
printf ("%02x ", currSlice->partArr[1].bitstream->streamBuffer[i]);
printf ("\n");
for (i=0; i<25; i++)
printf ("%02x ", currSlice->partArr[2].bitstream->streamBuffer[i]);
printf ("\n");
}
*/
  if(PartitionMask == -4711)
    return EOS;

  if(currSlice->start_mb_nr != 0)
    return SOS;
  else
    return SOP;
}

  
/*!
 ************************************************************************
 * \brief
 *    read all partitions of one slice from RTP packet stream, also handle
 *    any Parameter Update packets and SuUPP-Packets
 * \return
 *    -1 for EOF                                              \n
 *    Partition-Bitmask otherwise:
 *    Partition Bitmask: 0x1: Full Slice, 0x2: type A, 0x4: Type B 
 *                       0x8: Type C
 ************************************************************************
 */
int ReadRTPPacket (struct img_par *img, struct inp_par *inp, FILE *bits)
{
  Slice *currSlice = img->currentSlice;
  DecodingEnvironmentPtr dep;
  byte *buf;
  int i=0, dt=0;
  unsigned int last_mb=0, picid=0;
  int eiflag=1;
  static int first=1;
  RTPpacket_t *p, *nextp;
  RTPSliceHeader_t *sh, *nextsh;
  int DoUnread = 0;
  int MBDataIndex;
  int PartitionMask = 0;
  int done = 0;
  int err, back=0;
  int intime=0;
  int ei_flag;
  static int last_pframe=0, bframe_to_code=0;
  int b_interval;
  static unsigned int old_seq=0;
  int FirstMacroblockInSlice;

  assert (currSlice != NULL);
  assert (bits != 0);

  if (first)
  {
    currSlice->max_part_nr = MAX_PART_NR;   // Just to get a start
    ExpectedMBNr = 0;
    LastPicID = -1;
  }


  // Tenporal storage for this function only

  p=alloca (sizeof (RTPpacket_t));      // the RTP packet
  p->packet=alloca (MAXRTPPACKETSIZE);
  p->payload=alloca (MAXRTPPAYLOADLEN);
  nextp=alloca (sizeof (RTPpacket_t));  
  sh=alloca(sizeof (RTPSliceHeader_t));
  sh->RMPNIbuffer=NULL;
  sh->MMCObuffer=NULL;

  nextsh=alloca(sizeof (RTPSliceHeader_t));
  nextsh->RMPNIbuffer=NULL;
  nextsh->MMCObuffer=NULL;

  ExpectedMBNr = img->current_mb_nr;
  LastPicID = img->tr;

  done = 0;
  do  
  {
//    Filepos = ftell (bits);             // to be able to go back one packet
      
    if (RTPReadPacket (p, bits) < 0)    // Read and decompose
      return -4711;

    switch (p->payload[0] & 0xf)
    {
    case 0:       // Full Slice packet
    case 1:       // Partition type A packet
      done = 1;
      break;
 
    case 2:       // Partition B
    case 3:       // Partition C
      // Do nothing.  this results in discarding the unexpected Partition B, C
      // packet, which will later be concealed "automatically", because when
      // interpreting the next Partition A or full slice packet a range of
      // lost blocks is found which will be concealed in the usual manner.
      //
      // If anyonme comes up with an idea how to use coefficients without the
      // header information then this code has to be changed
      printf ("ReadRTPPacket(): found unexpected Partition %c packet, skipping\n", p->payload[0]&0xf==2?'B':'C');
      break;
    case 4:
      //! Compound packets may be handled here, but I (StW) would personally prefer and
      //! recommend to handle them externally, by a pre-processor tool.  For now,
      //! compounds lead to exit()
      printf ("Compound packets not yet implemented, exit\n");
      exit (-700);
      break;
    case 5:
      //! Add implementation of SUPP packets here
      printf ("SUPP packets not yet implemented, skipped\n");
      break;
    case 6:
      printf ("Found header packet\n");

      if ((err = RTPInterpretParameterSetPacket (&p->payload[1], p->paylen-1)) < 0)
      {
        printf ("RTPInterpretParameterSetPacket returns error %d\n", err);
      }
      break;
    default:
      printf ("Undefined packet type %d found, skipped\n", p->payload[0] & 0xf);
      assert (0==1);
      break;
    }
  } while (!done);

  // Here, all the non-video data packets and lonely type B, C partitions
  // are handled.  Now work on the expected type A and full slice packets

  assert ((p->payload[0] & 0xf) < 2);

  if ((p->payload[0] & 0xf) == 0)       // Full Slice packet
  {
    currSlice->ei_flag = 0;
    MBDataIndex = 1;                    // Skip First Byte
    MBDataIndex += RTPInterpretSliceHeader (&p->payload[1], p->paylen-1, 0, sh);
  }
  else                                  // Partition A packet
  {
    currSlice->ei_flag = 0;
    MBDataIndex = 1;                    // Skip First Byte
    MBDataIndex += RTPInterpretSliceHeader (&p->payload[1], p->paylen-1, 1, sh);
  }


  FirstMacroblockInSlice = sh->FirstMBInSliceY * (img->width/16) + 
                               sh->FirstMBInSliceX;   //! assumes picture sizes divisble by 16
  // The purpose of the following if cascade is to check for a lost
  // segment  of macroblocks.  if such a segment is found, a dummy slice
  // without content, but with ei_flag set is generated in order to trigger
  // concealment.
  if(first)
  {
    bframe_to_code = InfoSet.NumberBFrames+1;
  }

  if (LastPicID == sh->PictureID)   // we are in the same picture
  {
    first = FALSE;
    if (ExpectedMBNr == FirstMacroblockInSlice)
    {
      currSlice->partArr[0].bitstream->ei_flag = 0;    // everything seems to be ok.
    }
    else
    {
      if (FirstMacroblockInSlice == 0)
      {
        assert ("weird! PicID wrap around?  Should not happen\n");
      }
      else
      {
        //printf ("SLICE LOSS 1: Slice loss at PicID %d, macoblocks %d to %d\n",LastPicID, ExpectedMBNr, FirstMacroblockInSlice-1);
        back=p->packlen+8;
        fseek (bits, -back, SEEK_CUR);    

        //FirstMacroblockInSlice = (img->width*img->height)/(16*16);
        currSlice->ei_flag = 1;
        currSlice->dp_mode = PAR_DP_1;
        currSlice->start_mb_nr = ExpectedMBNr;
        //! just the same slice we just read!
        currSlice->next_header = RTPGetFollowingSliceHeader (img, nextp, nextsh); 
        assert (currSlice->start_mb_nr == img->current_mb_nr); 
#if _ERROR_CONCEALMENT_
        currSlice->last_mb_nr = FirstMacroblockInSlice-1;
#else
        currSlice->last_mb_nr = FirstMacroblockInSlice;
#endif
        currSlice->partArr[0].bitstream->bitstream_length=0;
        currSlice->partArr[0].bitstream->read_len=0;
        currSlice->partArr[0].bitstream->code_len=0;
        currSlice->partArr[0].bitstream->ei_flag=1;
          
        img->tr = currSlice->picture_id = LastPicID;
         
        return 0;
      }
    }
  }
  else      // we are in a different picture
  {
    b_interval = (int)((float)(InfoSet.FrameSkip +1)/(float)(InfoSet.NumberBFrames +1) + 0.49999);
    if (ExpectedMBNr == 0)    // the old picture was finished
    {
      if (((last_pframe + InfoSet.FrameSkip +1)%256) == sh->PictureID && 
           (bframe_to_code > InfoSet.NumberBFrames) && !first) //! we received a new P-Frame and coded all B-Frames
      {
        //! This P-Frame is the one we expected but maybe parts of it are lost!
        if(InfoSet.NumberBFrames)
        {
          last_pframe = sh->PictureID-(InfoSet.FrameSkip +1);
          if(last_pframe < 0)
            last_pframe += 256;
          bframe_to_code = 1;
        }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美成人午夜| 日韩在线一区二区三区| 美女在线视频一区| 国产精品一区在线观看乱码| 26uuuu精品一区二区| 久久se这里有精品| 久久久久久久久伊人| 国产福利视频一区二区三区| 亚洲国产高清在线| 色吧成人激情小说| 亚洲成人综合视频| 91麻豆精品国产91久久久久久久久| 天天操天天综合网| 精品黑人一区二区三区久久| 国产在线不卡一卡二卡三卡四卡| 久久综合九色欧美综合狠狠| 成人看片黄a免费看在线| 亚洲丝袜美腿综合| 欧美日韩aaa| 国精品**一区二区三区在线蜜桃| 欧美激情中文字幕| 日韩黄色在线观看| 在线综合亚洲欧美在线视频| 久久99蜜桃精品| 国产精品久久国产精麻豆99网站 | 丰满少妇久久久久久久| 国产欧美日韩麻豆91| 91老司机福利 在线| 天堂一区二区在线| 国产欧美一区二区三区鸳鸯浴| 波波电影院一区二区三区| 亚洲午夜激情网页| 国产偷国产偷精品高清尤物| 91福利视频网站| 狠狠色狠狠色合久久伊人| 国产精品久久久99| 日韩欧美中文字幕精品| jiyouzz国产精品久久| 午夜精品久久久久久久99水蜜桃| 久久久久国产精品人| 99久久久免费精品国产一区二区| 成人动漫中文字幕| 日本欧美韩国一区三区| 国产精品美女久久久久久久| 在线播放亚洲一区| 99精品国产91久久久久久| 日韩avvvv在线播放| 亚洲特级片在线| 久久久午夜电影| 在线综合视频播放| 在线观看av一区| 粉嫩一区二区三区性色av| 免费成人结看片| 一区二区久久久久| 国产成人夜色高潮福利影视| 亚洲专区一二三| 成人教育av在线| 欧美精品一区二区在线播放| 在线国产亚洲欧美| 成人黄色小视频| 久久电影国产免费久久电影| 亚洲免费在线观看| 日本一二三不卡| 久久这里只有精品6| 91麻豆精品国产综合久久久久久| 色噜噜久久综合| 9色porny自拍视频一区二区| 久久精品国产成人一区二区三区| 亚洲3atv精品一区二区三区| 1024成人网色www| 国产精品毛片久久久久久| 久久久综合精品| 久久影院午夜片一区| 日韩欧美一区中文| 91精品国产一区二区人妖| 色成年激情久久综合| 色综合久久中文字幕| 色综合夜色一区| 大尺度一区二区| 久久av老司机精品网站导航| 亚洲欧美国产高清| 精品一区二区三区免费毛片爱| 精品国产一区二区亚洲人成毛片| 91麻豆精品国产91久久久久久久久 | 99久久精品99国产精品| 成人av网站大全| 91首页免费视频| 91极品视觉盛宴| 欧洲精品视频在线观看| 欧美日韩免费高清一区色橹橹 | 国产精品欧美一区喷水| 国产精品区一区二区三区| 久久综合九色综合97_久久久| 日韩va亚洲va欧美va久久| 亚洲精品在线网站| 久久蜜桃香蕉精品一区二区三区| 国产午夜精品在线观看| 国产亚洲婷婷免费| 亚洲天堂中文字幕| 亚洲精品免费在线| 日日噜噜夜夜狠狠视频欧美人 | 亚洲三级理论片| 一区二区三区高清在线| 亚洲成av人**亚洲成av**| 五月开心婷婷久久| 韩国精品久久久| 成人国产精品视频| 在线欧美日韩精品| 日韩午夜激情av| 国产欧美视频一区二区三区| 中文字幕日韩欧美一区二区三区| 亚洲资源中文字幕| 精品一区精品二区高清| 成人午夜碰碰视频| 在线一区二区视频| 日韩一区二区免费高清| 国产日韩亚洲欧美综合| 亚洲欧美日本在线| 久久精品理论片| av毛片久久久久**hd| 欧美精品日日鲁夜夜添| 久久影院电视剧免费观看| 亚洲精品高清在线观看| 精品中文av资源站在线观看| 成人91在线观看| 91精品国产91久久综合桃花| 国产精品午夜在线观看| 日韩精品一级二级 | 国产精品成人免费精品自在线观看| 亚洲精品日韩一| 国产呦萝稀缺另类资源| 在线观看成人小视频| 久久综合九色欧美综合狠狠| 亚洲午夜私人影院| 国产91在线看| 欧美一区二区三区男人的天堂| 国产精品久久久久久久久免费丝袜| 午夜电影一区二区| av中文字幕一区| 久久综合五月天婷婷伊人| 亚洲综合成人在线视频| 成人精品免费视频| 精品国产一区二区在线观看| 亚洲综合偷拍欧美一区色| 风间由美一区二区av101| 日韩一级黄色片| 亚洲大片在线观看| 99精品热视频| 国产欧美一区二区精品性色| 免费欧美在线视频| 欧美日韩综合在线| 亚洲精品一二三| 成人ar影院免费观看视频| 欧美精品一区二区在线播放| 日本最新不卡在线| 欧美日韩精品久久久| 亚洲精品福利视频网站| 丁香啪啪综合成人亚洲小说| ww久久中文字幕| 午夜视频一区在线观看| 国产精品人人做人人爽人人添| 久久99精品国产麻豆婷婷| 欧美乱熟臀69xxxxxx| 一区二区三区加勒比av| 91麻豆国产在线观看| 亚洲欧洲成人自拍| 成人成人成人在线视频| 国产免费久久精品| 精品无人区卡一卡二卡三乱码免费卡| 欧美疯狂做受xxxx富婆| 五月天中文字幕一区二区| 欧美日韩免费观看一区二区三区| 亚洲一区av在线| 欧美三级蜜桃2在线观看| 一区二区三区在线高清| 欧美体内she精高潮| 午夜激情久久久| 日韩欧美第一区| 国产v综合v亚洲欧| 自拍视频在线观看一区二区| 色欧美乱欧美15图片| 亚洲综合小说图片| 91精品免费观看| 国产剧情一区在线| 国产精品色婷婷久久58| 91色婷婷久久久久合中文| 一区二区三区.www| 欧美一卡二卡三卡四卡| 国内精品免费**视频| 国产精品久久网站| 白白色亚洲国产精品| 亚洲精品乱码久久久久久久久| 成人福利视频在线| 椎名由奈av一区二区三区| 色婷婷久久久久swag精品| 午夜天堂影视香蕉久久| 欧美一区二区三区在线看| 国产一区二区三区不卡在线观看| 欧美成人性福生活免费看| 国产999精品久久久久久绿帽|