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

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

?? bitstream.c

?? AVS編解碼是學習AVS程序開發的入門資料,可以幫助初學者獲得很多的收獲.
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*****************************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2003, Advanced Audio Video Coding Standard, Part II
*
* DISCLAIMER OF WARRANTY
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations under
* the License.
*                     
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY.
* The AVS Working Group doesn't represent or warrant that the programs
* furnished here under are free of infringement of any third-party patents.
* Commercial implementations of AVS, including shareware, may be
* subject to royalty fees to patent holders. Information regarding
* the AVS patent policy for standardization procedure is available at 
* AVS Web site http://www.avs.org.cn. Patent Licensing is outside
* of AVS Working Group.
*
* The Original Code is Reference Software for China National Standard 
* GB/T 20090.2-2006 (short for AVS-P2 or AVS Video) at version RM52J.
*
* The Initial Developer of the Original Code is Video subgroup of AVS
* Workinggroup (Audio and Video coding Standard Working Group of China).
* Contributors:   Guoping Li,    Siwei Ma,    Jian Lou,    Qiang Wang , 
*   Jianwen Chen,Haiwu Zhao,  Xiaozhen Zheng, Junhao Zheng, Zhiming Wang
* 
******************************************************************************
*/


/*
*************************************************************************************
* File name: 
* Function:  Annex B Byte Stream format NAL Unit writing routines
*
*************************************************************************************
*/


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

#include "global.h"
#include "bitstream.h"
#define MAXHEADERSIZE 100
#include "vlc.h"

static FILE *f = NULL;    // the output file

CopyRight CopyRights, *cp = &CopyRights;
CameraParamters CameraParameter, *camera = &CameraParameter;

int seqstuffingflag=1; //added by cjw AVS Zhuhai 20070122

////////////////////////////////////////////////////////////////////////////////
#ifdef SVA_START_CODE_EMULATION

unsigned char bit[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
OutputStream  ORABS;
OutputStream *pORABS = &ORABS;

void OpenORABS(OutputStream *p,char *fname)
{
	p->f = fopen(fname,"wb");
	if(p->f==NULL){printf ("\nCan't open file %s",fname);exit(-1);}

	p->uPreBytes			= 0xffffffff;
	p->iBytePosition		= 0;
	p->iBitOffset			= 0;
	p->iNumOfStuffBits		= 0;
	p->iBitsCount			= 0;
}
void CloseORABS(OutputStream *p)
{
	if(p->iBitOffset)	fwrite(p->buf,1,p->iBytePosition+1,p->f);
	else				fwrite(p->buf,1,p->iBytePosition  ,p->f);
	fclose(p->f);
}
void FlushORABS(OutputStream *p)
{
	fflush(p->f);
}


int write_1_bit(OutputStream *p,int b)
{
	int i;

	if(p->iBytePosition == SVA_STREAM_BUF_SIZE)
	{
		i = fwrite(p->buf,1,SVA_STREAM_BUF_SIZE,p->f);
		if(i!=SVA_STREAM_BUF_SIZE)
		{
			printf ("Fatal: write file error, exit (-1)\n");
			exit (-1);
		}
		p->iBytePosition	= 0;
		p->iBitOffset		= 0;
	}
	p->uPreBytes <<= 1;
	if(b)
	{
		p->buf[p->iBytePosition] |= bit[p->iBitOffset];
		p->uPreBytes |= 1;
	}
	else
	{
		p->buf[p->iBytePosition] &= (~bit[p->iBitOffset]);
	}
	p->iBitOffset++;
	if(p->iBitOffset==8)
	{
		p->iBitOffset = 0;
		p->iBytePosition++;
	}
	p->iBitsCount++;
	return 0;
}
int write_n_bit(OutputStream *p,int b,int n)
{
	if(n>30) return 1;
	while(n>0)
	{
		write_1_bit(p,b&(0x01<<(n-1)));
		n--;
	}
	return 0;
}

// added by Yulj 2004.07.16
// one bit "1" is added to the end of stream, then some bits "0" are added to bytealigned position.
int write_align_stuff(OutputStream *p)
{
	unsigned char c;
	
	c = 0xff << ( 8 - p->iBitOffset );
	p->buf[p->iBytePosition] = ( c & p->buf[p->iBytePosition] ) | (0x80>>(p->iBitOffset));
	p->iBitsCount += 8 - p->iBitOffset;
	p->uPreBytes	= (p->uPreBytes << (8 - p->iBitOffset)) & c;
	p->iNumOfStuffBits	+= 8 - p->iBitOffset;
	p->iBitOffset = 0;
	p->iBytePosition++;
	return 0;
}
//---end
int write_start_code(OutputStream *p,unsigned char code)
{
	int i;
	 
	//modified by cjw&Zhenjunhao AVS Zhuhai 20070122
	if (p->iBitOffset || seqstuffingflag)  // 0x80 should inserted before the first seq-header
     write_align_stuff(p);
 
	  seqstuffingflag = 0;                       // only work for the first seq-header
 
	if(p->iBytePosition >= SVA_STREAM_BUF_SIZE-4 && p->iBytePosition >0 )
	{
		i = fwrite(p->buf,1,p->iBytePosition,p->f);
		if(i != p->iBytePosition){printf ("\nWrite file error");exit (-1);}
		p->iBytePosition	= 0;
		p->iBitOffset		= 0;
	}
	p->buf[p->iBytePosition  ] = 0;
	p->buf[p->iBytePosition+1] = 0;
	p->buf[p->iBytePosition+2] = 1;
	p->buf[p->iBytePosition+3] = code;
	p->iBytePosition += 4;
	p->iBitsCount += 32;
	p->uPreBytes	= (unsigned int)code + 256;

	return 0;
}

/*
*************************************************************************
* Function:Open the output file for the bytestream    
* Input: The filename of the file to be opened
* Output:
* Return: none.Function terminates the program in case of an error
* Attention:
*************************************************************************
*/


void OpenBitStreamFile(char *Filename)
{
	OpenORABS(pORABS,Filename);
}
void CloseBitStreamFile()
{
	CloseORABS(pORABS);
}

/*
*************************************************************************
* Function:Write video edit code
* Input:
* Output:
* Return: 32bit for video edit code
* Attention:
*************************************************************************
*/

int WriteVideoEditCode()
{
	Bitstream *bitstream;
	byte VideoEditCode[32];
	int  bitscount=0;

	if ((bitstream=calloc(1, sizeof(Bitstream)))==NULL)
		no_mem_exit("Seuqence Header: bitstream");
	
	bitstream->streamBuffer = VideoEditCode;
	bitstream->bits_to_go = 8;

	bitscount = u_v(32, "video_edit_code",0x1B7,bitstream);		
	
	write_start_code(pORABS, 0xb7);    //modified by cjw AVS Zhuhai 20070122

	free(bitstream);
	
  return bitscount;
}

/*
*************************************************************************
* Function:Write sequence header information
* Input:
* Output:
* Return: sequence header length, including stuffing bits
* Attention:
*************************************************************************
*/

int WriteSequenceHeader()
{
	Bitstream *bitstream;
	byte SequenceHeader[MAXHEADERSIZE];
	int  bitscount=0;
	int  stuffbits;
	int  i,j,k;
	if ((bitstream=calloc(1, sizeof(Bitstream)))==NULL)
		no_mem_exit("Seuqence Header: bitstream");
	
	bitstream->streamBuffer = SequenceHeader;
	bitstream->bits_to_go = 8;
	
//	input->profile_id = 0x20;		// Commented by cjw, 20070327
//	input->level_id   = 0x42;		// Commented by cjw, 20070327
	
	input->display_horizontal_size = img->width;  //add by wuzhongmou 0610
	input->display_vertical_size   = img->height; //add by wuzhongmou 0610
    input->sample_precision=1;//add by xfwang 2004.7.29
	input->bbv_buffer_size=122880;//here we random give a value,but in fact it is not true.  //add by wuzhongmou 200612
	input->aspect_ratio_information=1;    //add by wuzhongmou 0610
	input->bit_rate_lower=(input->bit_rate/400)&(0x3FFFF);  //add by wuzhongmou 0610
    input->bit_rate_upper=(input->bit_rate/400)>>18;    //add by wuzhongmou 0610
    
	//bitscount+=u_v(8,"stuffing bit",0x80,bitstream);    //add by wuzhongmou 200612 commented by cjw AVS Zhuhai 20070122
	bitscount+=u_v(32,"seqence start code",0x1b0,bitstream);
	bitscount+=u_v(8,"profile_id",input->profile_id,bitstream);
	bitscount+=u_v(8,"level_id",input->level_id,bitstream);
	
	bitscount+=u_v(1,"progressive_sequence",input->progressive_frame,bitstream); //add by wuzhongmou 0610
	bitscount+=u_v(14,"picture width",img->width,bitstream); //add by wuzhongmou 0610
	bitscount+=u_v(14,"picture height",img->height,bitstream); //add by wuzhongmou 0610
	bitscount+=u_v(2,"chroma foramt",input->chroma_format,bitstream);
	bitscount+=u_v(3,"sample precision",input->sample_precision,bitstream);
	bitscount+=u_v(4,"aspect ratio information",input->aspect_ratio_information,bitstream);
	bitscount+=u_v(4,"frame rate code",input->frame_rate_code,bitstream);
	
	//input->bit_rate_lower = input->bit_rate_upper = 0;
	//xyji 12.23
	bitscount+=u_v(18,"bit rate lower",input->bit_rate_lower,bitstream);
	bitscount+=u_v(1,"marker bit",1,bitstream);
	bitscount+=u_v(12,"bit rate upper",input->bit_rate_upper,bitstream);
	bitscount+=u_v(1,"low delay",input->low_delay,bitstream);
	bitscount+=u_v(1,"marker bit",1,bitstream);
	bitscount+=u_v(18,"bbv buffer size",input->bbv_buffer_size,bitstream);
	
	bitscount+=u_v(3,"reserved bits",0,bitstream);

	k = bitscount >> 3;
	j = bitscount % 8;

	stuffbits = 8-(bitscount%8);
	
	if (stuffbits<8)
		bitscount+=u_v(stuffbits,"stuff bits for byte align",0,bitstream);
	
	write_start_code(pORABS, 0xb0);    //modified by cjw AVS Zhuhai 20070122
	
	for(i=4;i<k;i++)  
		write_n_bit(pORABS,SequenceHeader[i],8); 

	write_n_bit(pORABS,SequenceHeader[k],j);
	write_align_stuff(pORABS);

	free(bitstream);
	
  return bitscount;
}

/*
*************************************************************************
* Function:Write sequence header information
* Input:
* Output:
* Return: sequence header length, including stuffing bits
* Attention:
*************************************************************************
*/


int WriteSliceHeader(int slice_nr, int slice_qp)
{
	Bitstream *bitstream;
	byte SequenceHeader[MAXHEADERSIZE];
	int  bitscount=0;
	int  stuffbits;
	int  i,j,k;
	
	if ((bitstream=calloc(1, sizeof(Bitstream)))==NULL)
		no_mem_exit("Seuqence Header: bitstream");
	
	bitstream->streamBuffer = SequenceHeader;
	bitstream->bits_to_go = 8;
	
	bitscount+=u_v(24,"start code prefix",1,bitstream);
	if(input->img_width > 2800)
		bitscount+=u_v(3, "slice vertical position extension",0,bitstream);
	 
	bitscount+=u_v(8, "slice start code",slice_nr,bitstream);
	 
	if (!input->fixed_picture_qp)
	{
		bitscount += u_v(1,"fixed_slice_qp",0,bitstream);//  [5/8/2007 Leeswan]
		bitscount += u_v(6,"slice_qp",slice_qp,bitstream);
	}

	k = bitscount >> 3;
	j = bitscount % 8;

	stuffbits = 8-(bitscount%8);
	
	if (stuffbits<8)
		bitscount+=u_v(stuffbits,"stuff bits for byte align",0,bitstream);
	
	write_start_code(pORABS, (unsigned char) slice_nr);
	for(i=4;i<k;i++)
		write_n_bit(pORABS,SequenceHeader[i],8);
	write_n_bit(pORABS,SequenceHeader[k],j);
	write_align_stuff(pORABS);

	//fwrite(SequenceHeader,1,(bitscount)/8,f);
	free(bitstream);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美在线另类| 成人午夜视频在线| 欧美亚洲国产一区在线观看网站| 最新中文字幕一区二区三区| 成人污污视频在线观看| 欧美不卡一区二区| 国产黄色91视频| 国产精品美女久久久久久久| 99精品热视频| 天堂资源在线中文精品| 欧美一级爆毛片| 884aa四虎影成人精品一区| 另类小说视频一区二区| 久久精品亚洲一区二区三区浴池| av一二三不卡影片| 亚洲最大成人网4388xx| 精品国精品自拍自在线| 高清不卡一区二区| 日本不卡视频一二三区| 亚洲国产精品成人久久综合一区| 在线国产亚洲欧美| 久久国内精品视频| 亚洲女人小视频在线观看| 色综合久久久久综合| 日韩一区在线播放| 欧美在线观看视频一区二区三区 | 福利视频网站一区二区三区| 中文字幕不卡的av| 色88888久久久久久影院按摩| 婷婷夜色潮精品综合在线| 2017欧美狠狠色| 色婷婷久久综合| 久久精品国产精品亚洲综合| 亚洲欧美日韩国产综合在线| 在线不卡中文字幕| 国产成人精品在线看| 日韩极品在线观看| 亚洲欧洲精品天堂一级| 欧美一级艳片视频免费观看| 成人污视频在线观看| 久久国产日韩欧美精品| 亚洲欧洲美洲综合色网| 欧美mv日韩mv国产网站app| 91丨porny丨国产入口| 国产精品一区一区三区| 日本aⅴ免费视频一区二区三区| 国产精品女同一区二区三区| 7777精品久久久大香线蕉| 91视频国产观看| 国产在线精品一区二区夜色 | 欧美一区二区三区四区五区| 日本大香伊一区二区三区| 丰满白嫩尤物一区二区| 国产精品综合在线视频| 久久精品国产久精国产爱| 亚洲影视资源网| 中文字幕在线观看不卡| 国产精品久久久久9999吃药| 国产日韩欧美精品电影三级在线 | 本田岬高潮一区二区三区| 粉嫩一区二区三区性色av| 狠狠狠色丁香婷婷综合激情 | 不卡视频一二三| 99久久er热在这里只有精品15| 国产suv精品一区二区6| youjizz国产精品| 91丨九色丨国产丨porny| 日本精品一级二级| 日韩一区二区视频| 国产精品福利av| 亚洲精品精品亚洲| 国产专区综合网| 91免费版在线| 国产日产欧美精品一区二区三区| 亚洲日本成人在线观看| 美女网站在线免费欧美精品| 色综合久久88色综合天天| 精品国产乱码久久久久久蜜臀| 亚洲欧美日韩成人高清在线一区| 裸体歌舞表演一区二区| 欧美手机在线视频| 国产精品福利一区| 高清成人在线观看| 亚洲国产精品精华液网站| youjizz久久| 国产精品国产馆在线真实露脸 | 亚洲综合男人的天堂| 国产精品99久久久久久似苏梦涵| 在线91免费看| 一卡二卡三卡日韩欧美| 91一区在线观看| 亚洲欧美中日韩| 欧美一区二区三区视频| 自拍偷拍国产亚洲| aaa亚洲精品一二三区| 最新热久久免费视频| 一本色道久久综合亚洲91| 亚洲欧美在线aaa| 色一区在线观看| 亚洲成人黄色小说| 91精品国产黑色紧身裤美女| 蜜桃91丨九色丨蝌蚪91桃色| 欧美变态口味重另类| 国产成人精品在线看| 亚洲欧洲性图库| 在线观看日韩av先锋影音电影院| 亚洲欧美日韩在线| 在线综合+亚洲+欧美中文字幕| 天天综合天天做天天综合| 久久美女艺术照精彩视频福利播放 | 日韩欧美电影在线| 国产91精品一区二区麻豆亚洲| 日韩伦理免费电影| 欧美日韩亚洲国产综合| 国产一区二区影院| 亚洲夂夂婷婷色拍ww47| 精品国产乱码久久久久久老虎| 国产高清精品在线| 日欧美一区二区| 精品国产区一区| 一区二区三区四区五区视频在线观看| 国产白丝精品91爽爽久久| 亚洲日本青草视频在线怡红院| 日韩一区二区电影在线| 国产精品影视网| 蜜桃av一区二区三区电影| 1000精品久久久久久久久| 精品国产乱码91久久久久久网站| 91视视频在线观看入口直接观看www| 日本欧美一区二区| 亚洲一区欧美一区| 国产午夜精品美女毛片视频| 欧美日韩免费高清一区色橹橹| 国产91在线|亚洲| 国产一区不卡在线| 午夜精品国产更新| 亚洲第一综合色| 一区二区三区美女视频| 中文字幕一区二区三区四区不卡| 日韩欧美中文一区| 欧美岛国在线观看| 日韩西西人体444www| 91麻豆精品国产| 欧美一区二区在线免费观看| 欧美日韩一区三区| 欧美精品日韩一区| 日韩美一区二区三区| 欧美一级日韩免费不卡| 欧美一区二区三区色| 日韩欧美成人一区| 国产亚洲va综合人人澡精品 | 精品久久久久av影院 | 欧美一级免费观看| 91精品国产色综合久久ai换脸| 欧美精品在线观看播放| 精品粉嫩aⅴ一区二区三区四区| 日韩欧美色综合网站| 久久久久九九视频| 亚洲视频免费在线观看| 亚洲第一综合色| 国产一区二三区| 色婷婷av一区二区三区大白胸| 欧美三级电影精品| 久久综合色婷婷| 亚洲精选在线视频| 奇米888四色在线精品| 97精品国产露脸对白| 日韩亚洲国产中文字幕欧美| 中文字幕一区av| 秋霞国产午夜精品免费视频 | 亚洲精品videosex极品| 黄一区二区三区| 欧美在线观看视频在线| 性做久久久久久| 成人久久久精品乱码一区二区三区| 日本韩国欧美三级| 久久亚洲一区二区三区四区| 亚洲一区二区三区自拍| 成人app网站| 国产欧美一区二区三区在线老狼| 日韩精品一二三四| 精品视频999| 亚洲午夜精品一区二区三区他趣| 国产精品一卡二卡| 欧美一区二区三区人| 日韩成人av影视| 欧美熟乱第一页| 午夜精品一区在线观看| 欧美综合视频在线观看| 亚洲乱码中文字幕| 91网上在线视频| 国产精品免费视频网站| 国产美女在线观看一区| 久久久99精品久久| 不卡免费追剧大全电视剧网站| 久久久无码精品亚洲日韩按摩| 精品一区二区三区免费观看| 日韩欧美国产一二三区| 国产精品99久久久久久似苏梦涵| 2022国产精品视频|