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

📄 parsemp4dsi.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 2 页
字号:
	{		// short_video_header = 0		temp = hwl_getbits(&BitParserContext,32,&Err);// video_object_layer_start_code		RMDBGLOG((TRACE, "\tvideo_obj_layer_start_code 0x%lx\n", temp));		temp = hwl_getbits(&BitParserContext,1,&Err);	// random_accessible_vol		RMDBGLOG((TRACE, "\trandom_accessible %lu\n", temp));		temp = hwl_getbits(&BitParserContext,8,&Err);	// video_object_type_indication		RMDBGLOG((TRACE, "\tvideo_obj_type %lu\n", temp));		temp = hwl_getbits(&BitParserContext,1,&Err);	// is_object_layer_identifier		if( temp == 1 )		{			temp = hwl_getbits(&BitParserContext,4,&Err);	// video_object_layer_verid should be 1			RMDBGLOG((TRACE, "\tvideo_obj_layer_verID %lu\n", temp));			if (temp != 1)				RMDBGLOG((ENABLE, "*** video_obj_layer_verID %lu != 1!!\n", temp));			temp = hwl_getbits(&BitParserContext,3,&Err);	// video_object_layer_priority			RMDBGLOG((TRACE, "\tvideo_obj_layer_priority %lu\n", temp));		}		temp = hwl_getbits(&BitParserContext,4,&Err);	// aspect_ratio_info		RMDBGLOG((TRACE, "\taspect_ratio_info 0x%lx\n", temp));		if( temp == 0xf )	// extended par		{			temp = hwl_getbits(&BitParserContext,8,&Err);	// par_width			RMDBGLOG((TRACE, "\t\twidth %lu\n", temp));			temp = hwl_getbits(&BitParserContext,8,&Err);	// par_height			RMDBGLOG((TRACE, "\t\theight %lu\n", temp));		}		temp = hwl_getbits(&BitParserContext,1,&Err);	// vol_control_parameters		if( temp == 1 )		{			temp = hwl_getbits(&BitParserContext,2,&Err);	// chroma_format			RMDBGLOG((TRACE, "\t\tchroma_format %lu\n", temp));			temp = hwl_getbits(&BitParserContext,1,&Err);	// low_delay			RMDBGLOG((TRACE, "\t\tlow_delay %lu\n", temp));			temp = hwl_getbits(&BitParserContext,1,&Err);	// vbv_parameters			if( temp == 1 )			{				temp = hwl_getbits(&BitParserContext,15,&Err);// first_half_bit_rate				RMDBGLOG((TRACE, "\t\t\tfirst_half_bit_rate %lu\n", temp));				temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit				temp = hwl_getbits(&BitParserContext,15,&Err);// latter_half_bit_rate				RMDBGLOG((TRACE, "\t\t\tlatter_half_bit_rate %lu\n", temp));				temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit				temp = hwl_getbits(&BitParserContext,15,&Err);// first_half_vbv_buffer_size				RMDBGLOG((TRACE, "\t\t\tfirst_half_vbv_buffer_size %lu\n", temp));				temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit				temp = hwl_getbits(&BitParserContext,3,&Err);	// latter_half_vbv_buffer_size				RMDBGLOG((TRACE, "\t\t\tlatter_half_vbv_buffer_size %lu\n", temp));				temp = hwl_getbits(&BitParserContext,11,&Err);// first_half_vbv_occupancy				RMDBGLOG((TRACE, "\t\t\tfirst_half_vbv_occupancy %lu\n", temp));				temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit				temp = hwl_getbits(&BitParserContext,15,&Err);// latter_half_vbv_occupancy				RMDBGLOG((TRACE, "\t\t\tlatter_half_vbv_occupancy %lu\n", temp));				temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit			}		}		temp = hwl_getbits(&BitParserContext,2,&Err);	// video_object_layer_shape		RMDBGLOG((TRACE, "\tvideo_obj_layer_shape %lu\n", temp));		temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit		vop_time_increment_resolution = hwl_getbits(&BitParserContext,16,&Err);		RMDBGLOG((ENABLE, ">>> DSI vop_time_increment_resolution = %d\n", vop_time_increment_resolution ));				// for now the output is a RMuint32 = vop_time_increment_resolution		*(RMuint32*)pDsiOut = vop_time_increment_resolution;		temp = hwl_getbits(&BitParserContext,1,&Err);	// marker_bit		temp = hwl_getbits(&BitParserContext,1,&Err);	// fixed_vop_rate		if(temp)		{			temp = 0;			while( vop_time_increment_resolution )			{				vop_time_increment_resolution >>= 1;				temp++;			}			temp = hwl_getbits(&BitParserContext,temp,&Err);	// fixed_vop_time_increment			RMDBGLOG((TRACE, "fixed_vop_rate %lu\n", temp));		}	}	return RM_OK;}static void hackDSI(RMuint8 *data, RMuint32 *size, RMuint32 samplingfreq, RMuint32 *channelCount, RMuint8 *objectID){	RMuint32 i;	RMuint8 hackedDSI[5];	RMDBGLOG((ENABLE, ">>>>> hacking DSI\n"));	hackedDSI[0] = 0;	hackedDSI[1] = 0;	hackedDSI[2] = 0;	hackedDSI[3] = 2;		hackedDSI[4] = *objectID << 3;	hackedDSI[4] |= samplingfreq >> 1;	hackedDSI[5] = samplingfreq << 7;	hackedDSI[5] |= 2 << 3;		*channelCount = 2;		*size = 6;	for (i = 0; i < 6; i++)		data[i] = hackedDSI[i];	return;}	RMstatus ParseMP4AudioDSI(RMuint8 *data, RMuint32 *size, RMuint32 *sampleRate, RMuint32 *channelCount, RMuint8 *objectID){	RMuint8 samplingfreq;	RMuint8 channels;	RMuint32 Err = 0;	RMuint32 temp;	struct BitStreamParserContext BitParserContext;	BitStream(&BitParserContext, (RMuint8*)data, *size, &Err);	/* audio DSI read by hw decoder needs the size as header! This is not part of the MP4 DSI though */	temp = hwl_getbits(&BitParserContext,5,&Err);	*objectID = (RMuint8) temp;	RMDBGLOG((ENABLE, "\tobj id %x\n", *objectID));	temp = hwl_getbits(&BitParserContext,4,&Err);	samplingfreq = (RMuint8) temp;	RMDBGLOG((ENABLE, "\tsampling id %x\n", samplingfreq));	if (samplingfreq == 0xf) {				temp = hwl_getbits(&BitParserContext,24,&Err);		*sampleRate = temp;	}	else {		switch(samplingfreq) {		case 0x0 :		//  96000			*sampleRate = 96000;			break;		case 0x1 : 		//  88200			*sampleRate = 88200;			break;		case 0x2 : 		//  64000			*sampleRate = 64000;			break;		case 0x3 : 		// 48000			*sampleRate = 48000;			break;		case 0x4 : 		//  44100													*sampleRate = 44100;			break;		case 0x5 : 		//  32000			*sampleRate = 32000;			break;		case 0x6 : 		//  24000			*sampleRate = 24000;			break;		case 0x7 : 		//  22050			*sampleRate = 22050;			break;		case 0x8 : 		//  16000			*sampleRate = 16000;			break;		case 0x9 : 		//  12000			*sampleRate = 12000;			break;		case 0xa : 		//  11025			*sampleRate = 11025;			break;		case 0xb : 		//  8000			*sampleRate = 8000;			break;		default :		//  44100			*sampleRate = 44100;			break;		}	}	RMDBGLOG((ENABLE, "\tsampling rate %lx(%ldHz)\n", *sampleRate, *sampleRate));	temp = hwl_getbits(&BitParserContext,4,&Err);	channels = (RMuint8) temp;	*channelCount = (RMuint32) channels;	if (*channelCount == 7) {		*channelCount = 8;	}else if (*channelCount == 0) { //number of channels is in Program_config_element		RMDBGLOG((ENABLE,"number of channels is in Program_Config_Element\n"));		if ((*objectID <= 7) && (*objectID != 5)) {			//GASpecificConfig			RMbool flag;						temp = hwl_getbits(&BitParserContext,1,&Err); //frameLengthFlag			flag = (temp != 0) ? TRUE : FALSE;						temp = hwl_getbits(&BitParserContext,1,&Err); //dependsOnCoreCoder			flag = (temp != 0) ? TRUE : FALSE;			if (flag) {				temp = hwl_getbits(&BitParserContext,14,&Err); //coreCoderDelay				RMDBGLOG((ENABLE, "coreCoderDelay: 0x%lx\n", temp));			}			temp = hwl_getbits(&BitParserContext,1,&Err); //extensionFlag			flag = (temp != 0) ? TRUE : FALSE;			if (*channelCount == 0) {				// ProgramConfigElement				temp = hwl_getbits(&BitParserContext,4,&Err); //element_instance_tag				RMDBGLOG((ENABLE, "element_instance_tag: 0x%lx\n", temp));				temp = hwl_getbits(&BitParserContext,2,&Err); //obj_type				RMDBGLOG((ENABLE, "obj_type: 0x%lx\n", temp));				temp = hwl_getbits(&BitParserContext,4,&Err); //sampling_freq_index				RMDBGLOG((ENABLE, "samplingFreqIndex: 0x%lx\n", temp));				if (temp != (RMuint32)samplingfreq) {					RMDBGLOG((ENABLE, ">>>>> Error: PCE samplingfreq != DSI samplingfreq, hacking DSI\n"));					hackDSI(data, size, samplingfreq, channelCount, objectID);				}			}			if ((*objectID == 6) || (*objectID == 20)) {				RMDBGLOG((ENABLE, "layerNr not supported\n"));			}			if (flag) { //extensionFlag				RMDBGLOG((ENABLE, "extensionFlag not supported\n"));			}		}	}	RMDBGLOG((ENABLE, "\tchannels %lx\n", *channelCount));	return RM_OK;}

⌨️ 快捷键说明

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