⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 header.c

📁 Mobile IP VCEG的信道模拟程序
💻 C
📖 第 1 页 / 共 2 页
字号:
		assert (input->of_mode <16);
		assert (input->partition_mode <8);
		assert (input->symbol_mode < 2);
		
		ProfileLevelVersionHash = input->of_mode<<0 | input->partition_mode<<4 | input->symbol_mode<<7;
		HeaderInfo = input->TRModulus | input->PicIdModulus<<12 | ProfileLevelVersionHash<<24;

		if (1 != fwrite (&HeaderInfo, 4, 1, outf)) {
			printf ("Error while writing Mini Sequence Header\n");
			exit (-501);
		}
#if TRACE
		fprintf(p_trace, "Binary Mini Sequence Header 0x%x\n\n", HeaderInfo);
#endif

		return 32;

	case 2:
		// An ASCII representation of many input file parameters, useful for debug purposes
		//
		//
		assert ("To be hacked");
		return -1;
	case 3:
		// An UVLC coded representatioj of the Sequence Header.  To be hacked.
		// Note that all UVLC initialization has already taken place, so just use
		// write_synyaxelement() to put the sequence header symbols.  Has to be double
		// checked whether this is true for cabac as well.  Do we need a new context
		// for that?  Anyway:
		//
		assert ("to be hacked");
		return -1;
	default:
		printf ("Unspported Sequence Header Type (should not happen since checked in n=input module, exiting\n");
		exit (-1);
	}
}

//********************************************************************************************
//********************************************************************************************
//
//  Local Support Functions
//
//********************************************************************************************
//********************************************************************************************

/*!
 *	\fn		PutPictureStartCode(Bitstream *s)
 *
 *	\brief	Puts a Picture Start Code into the Bitstream
 *
 *	\return	number of bits used for the PSC.
 *
 *	\note
 *
 *	-Side effects:
 *			Adds picture start code to the Bitstream
 *  -Remarks:
 *			THIS IS AN INTERIM SOLUTION FOR A PICTURE HEADER, see VCEG-M79
 *
 *			The PSC is a NAL functionality and, hence, should not be put into the
 *			bitstream by a module like this.  It was added here in response to
 *			the need for a quick hack for the MPEG tests.
 *			The PSC consists of a UVLC codeword of len 31 with info 0.  This results
 *			in 30 consecutove 0 bits in the bit stream, which should be easily
 *			identifyable if a need arises.
*/

static int PutPictureStartCode (Bitstream *s) {
	return PutStartCode (0, s, "\nPicture Header");
}


/*!
 *	\fn		PutSliceStartCode(Bitstream s)
 *
 *	\brief	Puts a Slice Start Code into the Bitstream
 *
 *	\return	number of bits used for the PSC.
 *
 *	\note
 *
 *  See PutPictureStartCode()
*/

static int PutSliceStartCode(Bitstream *s) {
	return PutStartCode (1, s, "\nSlice Header");
}

/*!
 *	\fn		PutStartCode(Bitstream s, char *ts)
 *
 *	\brief	Puts a Start Code into the Bitstream
 *			ts is a TraceString
 *	\return	number of bits used for the PSC.
 *
 *	\note
 *
 *  See PutPictureStartCode()
*/

static int PutStartCode (int Type, Bitstream *s, char *ts) {

	SyntaxElement sym;

	// Putting the Start Codes is a bit tricky, because we cannot use writesyntaxelement() 
	// directly.  Problem is that we want a codeword of len == 31 with an info of 0 or 1.  
	// There is no simple mapping() rule to express this.  Of course, one could calculate
	// what info would have to be for such a case.  But I guess it's cleaner to use
	// the len/info interface directly.  

	sym.len = LEN_STARTCODE;
	sym.inf = Type;
	sym.type = SE_HEADER;

#if TRACE
	strcpy(sym.tracestring, ts);
#endif
	symbol2uvlc(&sym);			// generates the bit pattern
	writeUVLC2buffer(&sym, s);	// and puts it out to the buffer

#if TRACE
	trace2out(&sym);
#endif
	return LEN_STARTCODE;
}

// StW Note: This function is a hack.  It would be cleaner if the encoder maintains
// the picture type in the given format.  Note further that I have yet to understand
// why the encoder needs to know whether a picture is predicted from one or more
// reference pictures.

/************************************************************************
*
*  Name :       select_picture_type()
*
*  Description: Selects picture type and codes it to symbol
*               
************************************************************************/
void select_picture_type(SyntaxElement *symbol)
{
	int multpred;

#ifdef _ADDITIONAL_REFERENCE_FRAME_
	if (input->no_multpred <= 1 && input->add_ref_frame == 0)
#else
	if (input->no_multpred <= 1)
#endif
		multpred=FALSE;
	else
		multpred=TRUE;               /* multiple reference frames in motion search */

	if (img->type == INTRA_IMG)
	{
		symbol->len=3;
		symbol->inf=1;
		symbol->value1 = 2;
	}
	else if((img->type == INTER_IMG) && (multpred == FALSE)) /* inter single reference frame */
	{
		symbol->len=1;
		symbol->inf=0;
		symbol->value1 = 0;
	}
	else if((img->type == INTER_IMG) && (multpred == TRUE)) /* inter multiple reference frames */
	{
		symbol->len=3;
		symbol->inf=0;
		symbol->value1 = 1;
	}
	else if((img->type == B_IMG) && (multpred == FALSE))	
	{
		symbol->len=5; 
		symbol->inf=0;
		symbol->value1 = 3;
	}
	else if((img->type == B_IMG) && (multpred == TRUE))
	{
		symbol->len=5;
		symbol->inf=1;
		symbol->value1 = 4;
	}
	else
	{		
		error("Picture Type not supported!");
	}

#if TRACE
	sprintf(symbol->tracestring, "Image type = %3d ", img->type);
#endif
	symbol->type = SE_PTYPE;
}


void LastMBInSlice() {
	int dP_nr = assignSE2partition[input->partition_mode][SE_HEADER];			
	Bitstream *currStream = ((img->currentSlice)->partArr[dP_nr]).bitstream;
	DataPartition *partition = &((img->currentSlice)->partArr[dP_nr]);
	SyntaxElement sym;
	int d_MB_Nr;
	
	d_MB_Nr = img->current_mb_nr-img->currentSlice->start_mb_nr;
	if (d_MB_Nr == img->total_number_mb)
		d_MB_Nr = 0;

	sym.type = SE_HEADER;				// This will be true for all symbols generated here
	sym.mapping = n_linfo2;				// Mapping rule: Simple code number to len/info

	// Put MB-Adresse
	assert (d_MB_Nr < (1<<15));
	SYMTRACESTRING("SH Numbers of MB in Slice");
	sym.value1 = d_MB_Nr;
	writeSyntaxElement_UVLC (&sym, partition);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -